This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
What is the maximum possible length of a .NET string?
Is there limit for a C# string to hold data?
Strings cannot have more than 231 characters, since String.Length is a 32-bit integer.
They're also limited by available memory.
string.Length is int, so string can contain Int.MaxInt bytes - 2,147,483,647
Related
This question already has answers here:
How can I convert String to Int?
(31 answers)
String.Format an integer to use a thousands separator with decimal value in danish culture
(5 answers)
How would I separate thousands with space in C#
(6 answers)
Closed 2 years ago.
I'm receiving a string value (for example "331000110.00") and I want to convert it so it has thousands separators (I want to have something like this: 331 000 110.00). Important thing is that I want this field to stay as a string. Anyone can help me with this?
This question already has answers here:
How do you convert a byte array to a hexadecimal string, and vice versa?
(53 answers)
Closed 8 years ago.
i have string like
string test = "0x527AE53437CAED39D3E2A8B3E90FFC3BA9073B6D933BC05FF6677B5521DC34"
How can i convert the string to byte[]?
use SoapHexBinary in namespace System.Runtime.Remoting.Metadata.W3cXsd2001
string s = "0x527AE53437CAED39D3E2A8B3E90FFC3BA9073B6D933BC05FF6677B5521DC34";
byte[] num = SoapHexBinary.Parse(s.Substring(2)).Value;
That string is hexadecimal.
If you want to convert it to a numeric you're going to need special handling - that's a very big number and will overflow the basic types.
If it was a reasonable size, all numeric types are agnostic of base-representation. To see a hexadecimal version of a number, you simply call .ToString("X") on it.
EDIT
My answer was based on the initial version of the question before the byte[] was specified. There is a previous SO question and answer for this: How can I convert a hex string to a byte array?
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
.NET String.Format() to add commas in thousands place for a number
I have an int that is passed through to the a view and it need to formatting so it is not one big block of number. e.g
0
00
000
000,0
000,000
000,000,000
How can i do this using a for loop?
thanks
You may want to output the integer as i.ToString("###,###,###");
However, this would not display a value if the int is 0.
You could try using System.Drawing.Color to represent the colour value rather than an int. This has a method ToArgb()
This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Split String into smaller Strings by length variable
I have seen solutions that split strings by a certain character but I wanted to seperate a string every certain amount of characters. Does anyone know how to do this?
its been asked
Split String into smaller Strings by length variable
This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
What is the maximum possible length of a .NET string?
I need to know how many characters a string can contain in C#?
Is it the same as the max length of a char array?
String.Length is an int so the its size is 2,147,483,647. But consider using StringBuilder if you find yourself asking this question !