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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Alok UniyalRank #8,369 · 223 reputationPosted Sep 17, 2012, 12:40 AM EDT
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];
VulpesRank #55 · 29.2K reputationPosted Sep 17, 2012, 12:41 AM EDT
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
Ruma8 reputationPosted Sep 17, 2012, 3:26 AM EDT
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);
RanjithKumar chiguruvada133 reputationPosted Sep 17, 2012, 5:17 AM EDT
Simply try this one.
string[] test={"a","b","c","d"};
for(int i=0;i
Console.WriteLine("{0}",test[i]);
}