سلام بر تمامی برنامه نویسان #C 😉 در این پست آموزش مقدار Default generic parameter در سی شارپ #C را آماده کردم. انشاالله که این کد براتون مفید باشه.
خروجی این کد به این صورت است:
True
True
True
کد مقدار Default generic parameter در سی شارپ #C :
using System;
public class Bag<T>
{
public Bag() {
// Create initial capacity.
imp = new T[ 4 ];
for( int i = 0; i < imp.Length; ++i ) {
imp[i] = default(T);
}
}
public bool IsNull( int i ) {
if( i < 0 || i >= imp.Length ) {
throw new ArgumentOutOfRangeException();
}
if( Object.Equals(imp[i], default(T)) ) {
return true;
} else {
return false;
}
}
private T[] imp;
public class Bag<T>
{
public Bag() {
// Create initial capacity.
imp = new T[ 4 ];
for( int i = 0; i < imp.Length; ++i ) {
imp[i] = default(T);
}
}
public bool IsNull( int i ) {
if( i < 0 || i >= imp.Length ) {
throw new ArgumentOutOfRangeException();
}
if( Object.Equals(imp[i], default(T)) ) {
return true;
} else {
return false;
}
}
private T[] imp;