Send a double to array
-
Hi I have an array and i want to put the ّFloat Variable into the array.
-
Hi I have an array and i want to put the ّFloat Variable into the array.
-
Hi I have an array and i want to put the ّFloat Variable into the array.
Are you wondering how to assign a variable to an array? If your array is a Float type then it's rather straight forward, see below.
float[] Variable = new float[ /*Insert how many index's the variable should hold*/ ];
Variable[0] = //insert variable hereBasically, the Variable[0] is the new variable array with the index (place of the array that you want to write on) which always begins at 0. So, in this case the first index of the array is 0, the second index is 1 and so on and so fourth. If you need to put a variable that isn't of the float type then you can convert it into that type using the command below.
Convert.toInt32();
Hope this has been of some help and I didn't make it seem over complicated! :P Best of luck learning c#. :)
-
What kind of array do you have? You can convert the float to another type for e.g. int by using
Convert.ToInt()
method[^]. If you need to convert the entire array to another type, use theConvertAll<>
method[^].A new Windows Phone App - Speed Dial
There is no problem in convert. I want to put each digit of float in each index of float array.
-
Hi I have an array and i want to put the ّFloat Variable into the array.
To "echo" the question raised by AbhinavS's comment: unless we know what type of array (array[float], array[int], array[double], array[?]) you have to begin with, and why you want to stick a float in it if the Array is not of Type 'float: we really can't answer this question. You might want to read about (from MSDN documentation) the 'Float type:[^]. And, may I also suggest you click on the links at the bottom of this page that lead to content on Implicit and Explicit conversion of numeric Types. In any case I suggest you think about using a Generic List, rather than an Array. Here's something else for you to think about:
// _you must declare the following 'using directiv_e
using System.Collections.Generic;
//
// this will compile, and what appear to be integers will be converted to type double
public List doubleList = new List {1, 2.0, 3.3333, 100038};
//
// this will not compile, because there is no implicit conversion of a double to a float
public List floatList = new List {1, 2.0, 3.3333};best, Bill
"Everything we call real is made of things that cannot be regarded as real." Niels Bohr