Skip to main content

All Questions

Tagged with
1186 votes
16 answers
1.6m views

How to convert UTF-8 byte[] to string

I have a byte[] array that is loaded from a file that I happen to known contains UTF-8. In some debugging code, I need to convert it to a string. Is there a one-liner that will do this? Under the ...
BCS's user avatar
  • 79.1k
388 votes
33 answers
866k views

Using C# to check if string contains a string in string array

I want to use C# to check if a string value contains a word in a string array. For example: string stringToCheck = "text1text2text3"; string[] stringArray = { "text1", "...
Theomax's user avatar
  • 6,828
538 votes
8 answers
527k views

.NET / C# - Convert char[] to string

What is the proper way to turn a char[] into a string? The ToString() method from an array of characters doesn't do the trick.
BuddyJoe's user avatar
  • 71.4k
304 votes
13 answers
383k views

How to access random item in list?

I have an ArrayList, and I need to be able to click a button and then randomly pick out a string from that list and display it in a messagebox. How would I go about doing this?
jay_t55's user avatar
  • 11.7k
210 votes
11 answers
409k views

C# declare empty string array

I need to declare an empty string array and i'm using this code string[] arr = new String[0](); But I get "method name expected" error. What's wrong?
aquanat's user avatar
  • 2,147
211 votes
10 answers
604k views

Check if a value is in an array (C#)

How do I check if a value is in an array in C#? Like, I want to create an array with a list of printer names. These will be fed to a method, which will look at each string in turn, and if the string ...
Steven Matthews's user avatar
203 votes
13 answers
554k views

Checking if a string array contains a value, and if so, getting its position

I have this string array: string[] stringArray = { "text1", "text2", "text3", "text4" }; string value = "text3"; I would like to determine if stringArray contains value. If so, I want to locate its ...
MoShe's user avatar
  • 6,487
0 votes
0 answers
42 views

Can I use the String.Split() method overloads while splitting at white-space characters without having to specify the white-space characters? [duplicate]

I'm trying to split a string into an array of strings. I want to split at every at white-space character and also use StringSplitOptions to remove and trim the empty entries. Is it somehow possible to ...
Rudolf Snail's user avatar
243 votes
9 answers
483k views

convert string array to string

I would like to convert a string array to a single string. string[] test = new string[2]; test[0] = "Hello "; test[1] = "World!"; I would like to have something like "Hello World!"
user avatar
346 votes
5 answers
328k views

Convert array of integers to comma-separated string

It's a simple question; I am a newbie in C#, how can I perform the following I want to convert an array of integers to a comma-separated string. I have int[] arr = new int[5] {1,2,3,4,5}; I want to ...
Haim Evgi's user avatar
  • 126k
1 vote
1 answer
81 views

Function is not working, but gives no error

I'm new to C#. I'm trying to make game in Unity. These functions are necessary for changing in-game tabs with help of a button. public string check; public CanvasGroup hydrogenScreen; public ...
Kārlis Kauliņš's user avatar
145 votes
4 answers
357k views

Convert an array to string

How do I make this output to a string? List<string> Client = new List<string>(); foreach (string listitem in lbClients.SelectedItems) { Client.Add(listitem); }
Rob's user avatar
  • 1,575
83 votes
12 answers
164k views

int array to string

In C#, I have an array of ints, containing digits only. I want to convert this array to string. Array example: int[] arr = {0,1,2,3,0,1}; How can I convert this to a string formatted as: "012301"?
user397232's user avatar
  • 1,808
0 votes
4 answers
120 views

How to concat various chunks of string array based on a condition

Lets say i have a string array like this, string[] array1 = { "<p>here is a big sentence</p>", "file1", "file2", "<p>this is a big ...
sharp12345's user avatar
  • 4,538
121 votes
10 answers
187k views

Is string in array?

What would be the best way to look in a string[] to see if it contains a element. This was my first shot at it. But perhaps there is something that I am overlooking. The array size will be no larger ...
Brad's user avatar
  • 21.3k

15 30 50 per page
1
2 3 4 5
89