[C#][System.Linq] Some convenient data processing methods (Range, Select)

[C#][System.Linq] Some convenient data processing methods (Range, Select) Because I am used to some convenient methods in Python, I immediately checked whether there are similar methods in C#. 1. Range() method In Python, range (Start, End, Step) can directly generate an iterable object, which can be used to process certain code blocks that need to be looped multiple times: (Note: End in the Range method is an open interval, and the actual value of range (1, 10) is (1 ~ 9)) 1 for item in range(1, 10 ): 2 print span>(item, end=”) 3 # span> Output: 4 # 123456789 The same method can be used in C#: Enumerable.Range(Start, Count) in the System.Linq namespace 1 foreach(int item in Enumerable.Range(1, 10 )) 2 Console.Write($”{item}=”); 3 // Output: 4 // 1=2=3=4=5=6=7=8=9=10= The parameters in range (Start, End, Step) and Enumerable.Range (Start, Count) have different meanings: range  is start, end, step, and the generated object does not include the End element. Range: The sequence is start, quantity, that is, starting from 1 and counting backwards 10 numbers, so the result of the above output is 1~10. If it is changed to Range(0, 10), the result will be 0~9. 2. Select() method It corresponds to…

GO language method, interface, reflection, select

Method method -Although the GO method does not have a class, it still has a method -Achieve combination with a certain type by displaying the description receiver -Only Define methods for types in the same package -RECEIVER can be a value or pointer of the type -There are no method overloads -You can use values ​​or pointers to When calling a method, the compiler will automatically complete the conversion -In a sense, the method is the syntactic sugar of the function, because the receiver actually It is the first parameter received by the method -If there are methods with the same name in the external structure and the embedded structure, the method of the external structure will be called first -Type aliases will not have methods attached to the underlying type -Method can call non-public fields in the structure ##method: package main import “fmt” type A struct { Name string } type B struct { Name string } func main() { a := A{} a.Printa() } func (a A) Printa() { fmt.Println(“A”) } Interface interface -An interface is a collection of one or more method signatures Reflection Concurrency Channel -Channel is a bridge for goroutine communication, most of which are…

Go language, channel, timer, select

Channel CSP communication sequence synchronization mechanism: After the program obtains the cpu wheel, execute Program, Goroutine will not give up the CPU usage rights when entering the suspended state, but will give the CPU usage rights to other Goroutines. The CPU content execution time is slow and inefficient. Exchanging usage rights within Goroutine can greatly improve switching efficiency. Channel pipes and characteristics: 1. The data in the channel can only flow in one direction 2. The data in the pipe can only be read once. Once read, it disappears and cannot be read again. 3. For data to flow correctly in the pipeline, both reading and writing ends must be online at the same time. Unbuffered channel: No buffer – no data can be stored, both ends must be online at the same time. Otherwise, it blocks until the peer is online. There is a cache channel: Comes with a buffer – the channel can store an appropriate amount of data according to the buffer size. Timer: ticker object under time package NewTicker creates a ticker object and sets the duration . Wait for the specified time and write the timestamp in the loop ticker.C The timer effect can be…

A complete list of Javascript select control operations (add, modify, delete, select, clear, determine existence, etc.)_Form special effects

1 Determine whether there is an Item with Value=”paraValue” in the select option 2 Add an Item to the select option 3 Delete an Item from the select option 4 Delete the selected item in the select 5 Modify the text of value=”paraValue” in the select option to “paraText” 6 Set the first Item of text=”paraText” in the select to be selected7 Set the Item of value=”paraValue” in the select to be selected 8 Get the value of the currently selected item of select 9 Get the text of the currently selected item of select 10 Get the Index of the currently selected item of select 11 Clear the item of selectjs code// 1. Determine whether there is an Item with Value=”paraValue” in the select option function jsSelectIsExitItem(objSelect, objItemValue) { var isExit = false; for (var i = 0; i < objSelect.options.length; i++) { if (objSelect.options[i].value == objItemValue) { isExit = true; break; } } return isExit; } // 2. Add an Item to the select option function jsAddItemToSelect(objSelect, objItemText, objItemValue) { //Determine whether it existsif (jsSelectIsExitItem(objSelect , objItemValue)) { alert(“The Value of this Item already exists”); } else { var varItem = new Option(objItemText, objItemValue); objSelect.options.add( varItem); alert(“Successfully added”);…

A complete collection of Javascript operation select methods [add, modify, delete, select, clear, determine existence, etc.]

js code// 1. Determine whether there is an Item with Value=”paraValue” in the select option function jsSelectIsExitItem(objSelect, objItemValue) { var isExit = false; for (var i = 0; i <objSelect.options.length; i++) { if (objSelect.options[i].value == objItemValue) { isExit = true; break; } } return isExit; } // 2. Add an Item to the select option function jsAddItemToSelect(objSelect, objItemText , objItemValue) { //Determine whether it existsif (jsSelectIsExitItem(objSelect, objItemValue)) { alert(“The Value of this Item already exists”); } else { var varItem = new Option(objItemText, objItemValue); objSelect.options.add(varItem); alert(“Successfully added”); } } // 3. Delete an Item from the select option function jsRemoveItemFromSelect(objSelect, objItemValue) { //Determine whether it existsif (jsSelectIsExitItem(objSelect, objItemValue)) { for (var i = 0; i <objSelect.options.length; i++) { if (objSelect.options[i].value == objItemValue) { objSelect.options.remove(i); break; } } alert(“Deleted successfully”); } else { alert(“This item does not exist in the selection”); } } // 4. Delete the selected item in selectfunction jsRemoveSelectedItemFromSelect(objSelect) { var length = objSelect.options.length – 1; for(var i = length; i >= 0; i–){ if(objSelect[i].selected == true){ objSelect.options[i] = null; } } } // 5. Modify the text of value=”paraValue” in the select option to “paraText” function jsUpdateItemToSelect( objSelect, objItemText, objItemValue) { //Determine whether it existsif (jsSelectIsExitItem(objSelect, objItemValue))…

A complete list of Javascript select control operations (add, modify, delete, select, clear, determine existence, etc.)

1 Determine whether there is an Item with Value=”paraValue” in the select option 2 Add an Item to the select option 3 Delete an Item from the select option 4 Delete the selected item in the select 5 Modify the text of value=”paraValue” in the select option to “paraText” 6 Set the first Item of text=”paraText” in the select to be selected7 Set the Item of value=”paraValue” in the select to be selected 8 Get the value of the currently selected item of select 9 Get the text of the currently selected item of select 10 Get the Index of the currently selected item of select 11 Clear the item of selectjs code// 1. Determine whether there is an Item with Value=”paraValue” in the select option function jsSelectIsExitItem(objSelect, objItemValue) { var isExit = false; for (var i = 0; i < objSelect.options.length; i++) { if (objSelect.options[i].value == objItemValue) { isExit = true; break; } } return isExit; } // 2. Add an Item to the select option function jsAddItemToSelect(objSelect, objItemText, objItemValue) { //Determine whether it existsif (jsSelectIsExitItem(objSelect , objItemValue)) { alert(“The Value of this Item already exists”); } else { var varItem = new Option(objItemText, objItemValue); objSelect.options.add( varItem); alert(“Successfully added”);…

A complete collection of Javascript operation select controls (add, modify, delete, select, clear, determine existence, etc.)

1 Determine whether there is an Item with Value=”paraValue” in the select option 2. Add an Item to the select option 3 Delete an Item from the select option 4Delete the selected item in select 5 Modify the text of value=”paraValue” in the select option to “paraText” 6Set the first Item with text=”paraText” in the select to be selected 7 Set the Item with value=”paraValue” in select to be selected 8 Get the value of the currently selected item of select 9 Get the text of the currently selected item of select 10 Get the Index of the currently selected item of select 11Clear selected items js code // 1. Determine whether there is an Item with Value=”paraValue” in the select option function jsSelectIsExitItem(objSelect, objItemValue) { var isExit = false; for (var i = 0; i <objSelect.options.length; i++) { if (objSelect.options[i].value == objItemValue) { isExit = true; break;                                                                                                                                                                 } return isExit; } // 2. Add an Item to the select option function jsAddItemToSelect(objSelect, objItemText, objItemValue) { //Determine whether it exists if (jsSelectIsExitItem(objSelect, objItemValue)) { alert(“The Value of this Item already exists”); } else { var varItem = new Option(objItemText, objItemValue); objSelect.options.add(varItem); alert(“Joined successfully”); } } // 3. Delete an…

Javascript operation select control encyclopedia (add, modify, delete, select, clear, determine existence, etc.)

Collect it 1. Determine whether there is an Item with Value=”paraValue” in the select option2. Add an Item to the select option3. Delete an Item from the select option4. Delete it from the select option Selected item5. Modify the text of value=”paraValue” in the select option to “paraText”6. Set the first Item with text=”paraText” in the select to be selected7. Set select The Item with value=”paraValue” is selected8. Get the value of the currently selected item of select9. Get the text of the currently selected item of select10. Get the Index of the currently selected item of select11. Clear selected items //js code// 1. Determine whether there is an Item with Value=”paraValue” in the select option function jsSelectIsExitItem(objSelect, objItemValue) { var isExit = false; for (var i = 0; i <objSelect.options.length; i++) { if (objSelect.options[i].value == objItemValue) { isExit = true; break; } } return isExit; } // 2. Add an Item to the select option function jsAddItemToSelect(objSelect, objItemText, objItemValue) { //Determine whether it exists if (jsSelectIsExitItem(objSelect, objItemValue)) { alert(“The Value of this Item already exists”); } else { var varItem = new Option(objItemText, objItemValue); objSelect.options.add(varItem); alert(“Successfully added”); } } / / 3. Delete an Item from the select option…

Convert JavaScript to operate select controls (add, modify, delete, select, clear, determine existence, etc.)…

Collect it 1. Determine whether there is an Item of Value=”paraValue” in the select option2. Add an Item to the select option3. From select Delete an Item in the options4. Delete the selected item in the select5. Modify the text of value=”paraValue” in the select option to “paraText”6. Set the text& in the select #61;The first Item of “paraText” is selected7. Set the value in select=The Item of “paraValue” is selected8. Get the value of the currently selected item of select9. Get the text of the currently selected item of select10. Get the Index of the currently selected item of select11. Clear the selected items //js code // 1. Determine whether there is an Item of Value=”paraValue” in the select option function jsSelectIsExitItem(objSelect, objItemValue) { var isExit = false; for (var i = 0; i < objSelect.options.length; i++) {         if (objSelect.options[i]. value == objItemValue) { isExit = true;                                                                                                                                                              > return isExit; } // 2. Add an Item to the select option function jsAddItemToSelect(objSelect, objItemText, objItemValue) {  //Determine whether it exists  if (jsSelectIsExitItem(objSelect, objItemValue)) { alert(“The Value of this Item already exists”); } else { var varItem = new Option(objItemText , objItemValue); objSelect.options.add(varItem); alert( “Joined successfully”); } } // 3.…

Problem with php regular expression html tag matching input, select, textarea

I want to use regular expressions to match the input, select and textarea tags in the html code, and no other tags are needed. My writing is as follows: $text = “”; $pattern=”//i”; preg_match($pattern1,$text,$matches); var_dump($matches); But I found that what I wrote can match all tags. I know that [input|textarea|select] is wrong, but I don’t know how to modify it or is there a simpler way? How to write it, I hope someone can give me an answer. Reply content: I want to use regular expressions to match the input, select and textarea tags in the html code, and no other tags are needed. My writing is as follows: $text = “”; $pattern=”//i”; preg_match($pattern1,$text,$matches); var_dump($matches); But I found that what I wrote can match all tags. I know that [input|textarea|select] is wrong, but I don’t know how to modify it or is there a simpler way? How to write it, I hope someone can give me an answer. [] means matching specified characters, not strings (string1|string2) matches multiple strings (?! string1) matches non string The correct one is: //is For example [a-zA-z0-9_\-] means matching a~z A~Z 0~9 _ – these characters (only one character) [a-zA-z0-9_\-]* means matching a~z A~Z 0~9…

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索