I have a list array named "list". I need to convert this list into a hex string. I tried the code below but it hasn't worked.       var  list = objIPLayer.Udp.Payload.ToList();     string hex = BitConverter.ToString(list);    I got this error:     The best overloaded method match for   'System.BitConverter.ToString(byte[])' has some invalid arguments**   when executed the following code.  string hex = BitConverter.ToString(list);    Is there any method to do this?
2031
How can you convert a byte array to a hexadecimal string, and vice versa?
11412
Is there any easy LINQ expression to concatenate my entire List&lt;string&gt; collection items to a single string with a delimiter character?  What if the collection is of custom objects instead of string? Imagine I need to concatenate on object.Name.
59820
What is the most efficient way in C# 2.0 to check each character in a string and return true if they are all valid hexadecimal characters and false otherwise? Example void Test() {     OnlyHexInString(&quot;123ABC&quot;); // Returns true     OnlyHexInString(&quot;123def&quot;); // Returns true     OnlyHexInString(&quot;123g&quot;); // Returns false }  bool OnlyHexInString(string text) {     // Most efficient algorithm to check each digit in C# 2.0 goes here }
34299
How do you convert between hexadecimal numbers and decimal numbers in C#?
110
Can we convert a hex string to a byte array using a built-in function in C# or do I have to make a custom method for this?
113807
Why does the following code not work?  I want to instantiate prefabs in a list and then use  it as a GameObject like that :  public GameObject prefab;  void Start() {   ArrayList players = new ArrayList();    for(int i=0; i&lt;5; i++)   {         players.Add( (GameObject)Instantiate(prefab));   }    players[2].transform.position = new Vector3(1, 1, 1);  }   there is an error message
7882
What's the best way to convert a string to an enumeration value in C#? I have an HTML select tag containing the values of an enumeration. When the page is posted, I want to pick up the value (which will be in the form of a string) and convert it to the corresponding enumeration value. In an ideal world, I could do something like this: StatusEnum MyStatus = StatusEnum.Parse(&quot;Active&quot;);  but that isn't a valid code.
104167
What is the most elegant method for dumping a list in python into an sqlite3 DB as binary data (i.e., a BLOB cell)?  data = [ 0, 1, 2, 3, 4, 5 ] # now write this to db as binary data # 0000 0000 # 0000 0001 # ... # 0000 0101
83735
private void activateRecords(long[] stuff) {     ...     api.activateRecords(Arrays.asList(specIdsToActivate));   }   Shouldn't this call to Arrays.asList return a list of Longs?  Instead it is returning a List&lt;long[]&gt;  public static &lt;T&gt; List&lt;T&gt; asList(T... a)   The method signature is consistent with the results, the varargs throws the entire array into the list.  It's the same as new ArrayList(); list.add(myArray)  And yes, I know it's meant to be used like this: Arrays.asList(T t1, T t2, T t3)  I guess what I'm getting at, is instead of the varargs form, why can't I just have my old asList method (at least I think this is how it used to work) that would take the contents and put them individually into a list?  Any other clean way of doing this?
30627
In C# the Main class has string[] args parameter.  What is that for and where does it get used?
43660
I have a list of structs and I want to change one element. For example :  MyList.Add(new MyStruct("john"); MyList.Add(new MyStruct("peter");   Now I want to change one element:  MyList[1].Name = "bob"   However, whenever I try and do this I get the following error:     Cannot modify the return value of   System.Collections.Generic.List.this[int]‘ because it is not   a variable   If I use a list of classes, the problem doesn't occur.  I guess the answer has to do with structs being a value type.  So, if I have a list of structs should I treat them as read-only? If I need to change elements in a list then I should use classes and not structs?
12987
What is the prefered method for creating a byte array from an input stream?   Here is my current solution with .NET 3.5.   Stream s; byte[] b;  using (BinaryReader br = new BinaryReader(s)) {     b = br.ReadBytes((int)s.Length); }   Is it still a better idea to read and write chunks of the stream?
19599
What is the best way to randomize an array of strings with .NET? My array contains about 500 strings and I'd like to create a new Array with the same strings but in a random order.  Please include a C# example in your answer.
17166
I have a list of integers, List&lt;Integer&gt; and I'd like to convert all the integer objects into Strings, thus finishing up with a new List&lt;String&gt;.  Naturally, I could create a new List&lt;String&gt; and loop through the list calling String.valueOf() for each integer, but I was wondering if there was a better (read: more automatic) way of doing it?
112859
Is there a better way to do this?  string[] s = {"zero", "one", "two", "three", "four", "five"};  var x =  s .Select((a,i) =&gt; new {Value = a, Index = i}) .Where(b =&gt; b.Value.StartsWith("t")) .Select(c =&gt; c.Index);   i.e. I'm looking for a more efficient or more elegant way to get the positions of the items matching the criteria.
52590
When I have a Set of Id's and I want to do a dynamic SOQL query that I want to use it in for an IN comparison, I have to convert the Set to string in the format of:  ('id1','id2',id3',...)   The way I do it works, but is not particularly elegant, so I'm wondering if anyone has come up with a better way. Am I missing something? Is there something out there that can just turn a set or list into the properly formatted string?   Here's my code (yes, my example isn't dynamic SOQL, but I've used this several times in dynamic SOQL):   Map&lt;Id,Account&gt; accts = new Map&lt;Id,Account&gt;([select Id from Account]);  String idString = '(\''; for (Id thisId : accts.keyset()) {     idString += thisId + '\',\''; } idString = idString.substring(0,idString.length()-2); //&lt;--this is the bit I hate doing idString += ')';  String q = 'select id from Contact where AccountId in ' + idString;  List&lt;Contact&gt; cts = Database.query(q);
81129
I have an ArrayList that I want to output completely as a String. Essentially I want to output it in order using the toString of each element separated by tabs. Is there any fast way to do this? You could loop through it (or remove each element) and concatenate it to a String but I think this will be very slow.