Topic:   How can we remove unassigned index of buffer to avoid memory overflow exception (in case of havy buffer).
Oct 15, 2020 07:06 1 Replies 746 Views ANANYA

char[] buffer = new char[10];

buffer[0] = '1';           

Console.Write(new String(buffer));

 

Output of below above code is "1\0\0\0\0\0\0\0\0\0"

Prev Next
Topic Replies (1)
  1. 1
    idnkx user

    PARTH

    You can do something like this -

    Example :
    string[] x = new string[] { "1", "", "2", "", "3", "4" };
    List y = x.ToList();
    y.RemoveAll(p => string.IsNullOrEmpty(p));
    x = y.ToArray()

Leave a Reply
Guest User

Not sure what course is right for you?

Choose the right course for you.
Get the help of our experts and find a course that best suits your needs.


Let`s Connect