Hi all,
i want to get all value of array except last value..
For ex.. string [] test ={"a","b","c","d"}
this my array now i want all values in my array but but i want to remove the last one.
plz help.
Hi all,
i want to get all value of array except last value..
For ex.. string [] test ={"a","b","c","d"}
this my array now i want all values in my array but but i want to remove the last one.
plz help.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Alok UniyalPosted Sep 17, 2012, 4:40 AM
string [] test ={"a","b","c","d"};
string []temp=new string[test.length-1];
for(int i=0;i< test.length-1 ;i++)
temp[i]=test[i];
RanjithKumar chiguruvadaPosted Sep 17, 2012, 9:17 AM
Simply try this one.
string[] test={"a","b","c","d"};
for(int i=0;i
Console.WriteLine("{0}",test[i]);
}
RumaPosted Sep 17, 2012, 7:26 AM
string[] test = new string []{ "a", "b", "c", "d" };
temp = test.Take(test.Length-1).ToArray();
foreach (string s in temp) Console.Write("{0} ", s);
If we want to remove the first one:
string[] test = new string[]{ "a", "b", "c", "d" };
string[] temp = test.Skip(test.Length - (test.Length - 1)).ToArray();
foreach (string s in temp) Console.Write("{0} ", s);
VulpesPosted Sep 17, 2012, 4:41 AM
string [] test ={"a","b","c","d"};
Array.Resize(ref test, test.Length - 1);
foreach(string s in test) Console.Write("{0} ", s); // a b c