1
Answer

c# fundamentals

why we are not using pointer in c#?
what is reflection in .net?
can we call a function under another function? 

Answers (1)

1
Photo of Amit Gupta
NA 16.5k 25.7k 8y
As you are fetching values under a loop that runs arNama.length, you can also initialize your variable with the fixed array size
var markers = new int [arNama.Length];
 
Or you can create dynamic creation of arrays as manas has pointed out
0
Photo of mega sarasvari
NA 37 2k 8y
hi mr. Manas and mr. Amit thanks for reply my question. I try to use code's mr. Amit but code result always the last value not all value. let see my script on java script :
 
var strNama = document.getElementById('<%=keyidnama.ClientID %>').value;
var strBusur= document.getElementById('<%=keyBusur.ClientID %>').value;
var strLintang= document.getElementById('<%=keyLintang.ClientID %>').value;
var strAlamat= document.getElementById('<%=keyAlamat.ClientID %>').value;
var arNama = strNama.split('~');
var arBusur= strBusur.split('~');
var arLintang= strLintang.split('~');
var arAlamat=strAlamat.split('~');
var markers = [arNama.length];
for(var i = 0; i < arNama.length; i++) {
markers = [
[i, arNama[i], arLintang[i], arBusur[i], arAlamat[i]],

];
}
 
oh, mr. manas thanks for your code, I used to in my code behind it's work
0
Photo of Manas Mohapatra
NA 29.3k 3.3m 8y
If you want array needs to be variable length then you need to use ArrayList or List.See below code: 
  1. ArrayList list = new ArrayList();  
  2. list.Add(1);  
  3. list.Add(2);  
  4. list.Add(3);  
  5.   
  6. foreach (int i in list)  
  7. {  
  8.     Console.WriteLine(i);  
  9. }