Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

non null array length

public static <T> int getLength(T[] arr){
    int count = 0;
    for(T el : arr)
        if (el != null)
            ++count;
    return count;
}

// equivalently in pure C# :
public static int getUsedLength(string[] arr)
        {
            int count = 0;
            for (int i = 0; i < arr.Length; i++)
            {
                if (arr[i] != null)
                { 
                    ++count; 
                }
            }
            return count;
        }
Comment

PREVIOUS NEXT
Code Example
Csharp :: concatenation on different lines in f# 
Csharp :: error cs1585 unity 
Csharp :: muovere un elemento in c# 
Csharp :: exit form esc winforms 
Csharp :: unity image button 
Csharp :: check .net installing 
Csharp :: mongodb custom IIdGenerator 
Csharp :: if session is not active then redirect to login page mvc.net 
Csharp :: unity mathf.clamp 
Csharp :: Read csv file into wpf C# 
Csharp :: C# wpf show hidden window 
Csharp :: remove loading bars devexpress on callback 
Csharp :: how to hide cell in epplus 
Csharp :: asp.net core 6 get current culture in controller 
Csharp :: VSIX Project Context Menu 
Csharp :: how to get user browser information in .net core 
Csharp :: data types of document in asp dot net frame work 
Csharp :: how to check if data already exists in database in c# mvc 
Csharp :: array of objects c# 
Csharp :: hierachical table to c# class 
Csharp :: Click an HTML link inside a WebBrowser Control 
Csharp :: ActionExecutingContext result response return objects 
Csharp :: declare a delegate 
Csharp :: how to create an initialized jtoken c# 
Csharp :: How to set a Printer Port in C# on a specified Printer 
Csharp :: Getting the ID of the element that fired an event 
Csharp :: TextBox filling in C# 
Csharp :: check null type 
Csharp :: same click method lots of buttons c# 
Csharp :: instance vs initiate 
ADD CONTENT
Topic
Content
Source link
Name
4+7 =