Tuesday, April 28, 2009

C# Convert string to double array

How to convert a string or a string array into a double array?
The .NET does not provide any method for us to call directly. However this is easy to implement within just a couple lines of code.

//str is the input string that contains a sequence of numbers
string[] arrString = str.Split(new char[] { ' ' });//you can define your own way to split the string

double[] arrDouble = new double[arrString.Length];
for (int i = 0; i < arrString.Length; i++)
arrDouble[i] = double.Parse(arrString[i]);


1 Response to "C# Convert string to double array"
  1. Rahul said...
    December 30, 2009 at 2:08 AM


    First of all. Thanks very much for your useful post.

    I just came across your blog and wanted to drop you a note telling you how impressed I was with the information you have posted here.

    Please let me introduce you some info related to this post and I hope that it is useful for .Net community.

    There is a good C# resource site, Have alook



Post a Comment



Copyright 2009 All Rights Reserved Revolution Two Lifestyle theme by Brian Gardner | Blogger template converted & enhanced by eBlog Templates