سلام بر تمامی برنامه نویسان #C 😉 در این مطلب کد generic method در سی شارپ #C را آماده کردم. انشاالله که این آموزش برای شما مفید باشد.
خروجی کد به این صورت می باشد :
True
True
True
کد generic method در سی شارپ #C :
using System;
class ArrayUtils {
public static bool isBigger<T>(T[] src, T[] target) {
// See if target array is big enough.
if(target.Length < src.Length+1)
return false;
return true;
}
}
class GenMethDemo {
public static void Main() {
int[] nums = { 1, 2, 3 };
int[] nums2 = new int[4];
// Operate on an int array.
bool b = ArrayUtils.isBigger(nums, nums2);
class ArrayUtils {
public static bool isBigger<T>(T[] src, T[] target) {
// See if target array is big enough.
if(target.Length < src.Length+1)
return false;
return true;
}
}
class GenMethDemo {
public static void Main() {
int[] nums = { 1, 2, 3 };
int[] nums2 = new int[4];
// Operate on an int array.
bool b = ArrayUtils.isBigger(nums, nums2);