چند نکتهی کاربردی در #C
نویسنده: فلونی
تاریخ: ۱۳۹۴/۰۸/۱۲ ۲۰:۰
آدرس: www.dntips.ir
| مطالب | ۳۶۹۴ |
| نویسندگان | ۲۷۶ |
| گروههای مطالب | ۱۰۲۴ |
| نقشههای راه | ۱۱۹ |
| دورهها | ۱۴ |
| اشتراکها | ۱۷۹۱۴ |
private Tuple<string, string, int> GetPersonInfo()
{
return new Tuple<string, string, int>("Steve", "Jobs", 56);
} private IEnumerable<int> GetNumbers()
{
var result = new List<int>();
for (int i = 0; i <= 100; i++)
result.Add(i);
return result;
} private IEnumerable<int> GetNumbers()
{
for (int i = 0; i <= 100; i++)
{
yield return i;
}
} public interface ICar
{
string GetName();
string GetManufacturerCompany();
}
private class GenricClass<T> where T : ICar
{
} public class Audi : ICar
{
public string GetName()
{
throw new NotImplementedException();
}
public string GetManufacturerCompany()
{
throw new NotImplementedException();
}
}
private static void Main(string[] args)
{
var invalidTest = new GenricClass<int>();
var validTest = new GenricClass<Audi>();
}