声明类型为泛型。

说明传递的参数为泛型,而不仅仅是一种类型。
public void aa<T>(T a)
{
Console.WriteLine(a);
}
调用时可写:
this.aa<int>(5);
this.aa(string)("aaaa");

例如:
int? id = null;
string? name = null;
还有如:

public int?[] InsertTest(int? parentId, string name, DateTime? publishTime, decimal? price, bool? isGood, out int? minId)
    {
        // 仅为说明如何做错误处理
        if (String.IsNullOrEmpty(name))
            throw new ArgumentException("参数不能是空", "name");
 
        int? id = null;
        int? count = null;
        minId = null;
 
        Singleton<TestTableAdapter>.Instance.InsertTest(parentId, name, publishTime, price, isGood, ref id, ref count, ref minId);
        return new int?[] { id, count };
    }
更多 2
View Code

相关文章:

  • 2021-08-30
  • 2022-12-23
  • 2021-08-01
  • 2021-06-26
  • 2021-11-17
  • 2022-12-23
  • 2021-11-02
  • 2021-07-20
猜你喜欢
  • 2021-11-11
  • 2021-09-02
  • 2022-12-23
  • 2022-12-23
  • 2021-08-24
  • 2021-05-18
  • 2022-12-23
相关资源
相似解决方案