Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I want convert 1,2,3,4,5,6,7,8,9,10 String to Double.
I tried Convert.ToDouble(String); and Double.Parse(String); but returned 1.0
How to convert multi comma string to double?
Thanks for help.
From the looks of your question you actually have 10 numbers not 1. Use this code:
var nums = "1,2,3,4,5,6,7,8,9,10";
var digits = nums.Split(',').Select(r => Convert.ToDouble(r)).ToArray();
// the result will be an array of doubles, also this only works with .NET 3.5 or better.
Let me know if this works for you.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
Will the C# function Convert.ToInt32(text) convert different words to the same int? Any links or pushes in the right direction are appreciated!
P.S.
What about anagrams?
No, Convert.ToInt32(text) will just try to parse your text to an int, like:
Convert.ToInt32("032") will return 32 as int but
Convert.ToInt32("Brian") will throw an exception.
I assume that you want to have some kind of hashing, when you say "different words to the same int".
Try GetHashCode(). It will return the same value if you call it multiple times with the same value, for example:
"Brian".GetHashCode() will always return 1635321435
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
Convert a string into mac address as example 0000001 need to change as 00:00:01 In php i can get it by this $HexVal=rtrim(strtoupper(chunk_split($hexval, 2, ':')),':'); i need exactly same in C#.
I have the first 6 value as 00:01:AB and i got the last six value from a decimal number. If i input 1 then it needs to change as 00:00:01. so then i con-cat to get my full mac as 00:00:AB:00:00:01.
OK got it,,
var temp = Regex.Replace("000001", ".{2}", "$0:");
var tempo = temp.Remove(temp.Trim().Length - 1);//or
var tempo = temp.Trim(':');
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I need to trim the trailing spaces at the start and end in this int array and how can I do it, also I am not getting Trim() function anywhere here. Pls suggest me.
int[] arrPCT = dtOld.AsEnumerable().Select(r => r.Field<int>("PCT")).ToArray();
int are numeric values. They don't contain spaces (or any other char). It makes no sense trying to trim them.
int[] arrPCT = dtOld.AsEnumerable().Select(r => r.Field<int>("PCT").Trim()).ToArray();
If r.Field("PCT") value is of string type.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
How do i create a six digit sequence number in c# ?
Is there any other way than storing a string in the database like "000000" and later on incrementing it through the last inserted value ?
Use a plain old number as a sequence, this is what your DB will provide. If you want to display it with six digits, just call: yourNumber.ToString("D6")
(see docs)
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I want to gain a true or false answer if this variable is enable to be converted from string into a int value.
Is there a build-in syntax for it in C#?
Use int.TryParse
string numberString = "123";
int number;
bool isConvertible = int.TryParse(numberString, out number);