Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

memset alternative in c#

var arr = GenerateArray(3, 4,-1);
//  first is row, second is col
// third  determine type  of  data in array  as well as 
// what elements should we put to fill the array
public static T[][] GenerateArray<T>(int row, int Col,T value)
{
    var arr = new T[row][];

    for (int i = 0; i < row; i++)
    {
        arr[i] = new T[Col];
        for (int j = 0; j < Col; j++)
        {
            arr[i][j] = value;
        }
    }
    return arr;
}
 
PREVIOUS NEXT
Tagged: #memset #alternative
ADD COMMENT
Topic
Name
5+4 =