小编Sar*_*rit的帖子

通用方法使用运行时类型执行

我有以下代码:

 public class ClassExample
{

    void DoSomthing<T>(string name, T value)
    {
        SendToDatabase(name, value);
    }

    public class ParameterType
    {
        public readonly string Name;
        public readonly Type DisplayType;
        public readonly string Value;

        public ParameterType(string name, Type type, string value)
        {
            if (string.IsNullOrEmpty(name))
                throw new ArgumentNullException("name");
            if (type == null)
                throw new ArgumentNullException("type");

            this.Name = name;
            this.DisplayType = type;
            this.Value = value;
        }
    }

    public void GetTypes()
    {
        List<ParameterType> l = report.GetParameterTypes();

        foreach (ParameterType p in l)
        {
            DoSomthing<p.DisplayType>(p.Name, (p.DisplayType)p.Value);
        }

    }
} …
Run Code Online (Sandbox Code Playgroud)

c# generics methods

30
推荐指数
2
解决办法
2万
查看次数

java中可用的单元测试框架是什么?

有哪些技术?(我只知道JUnit)最受欢迎的是什么?你能解释一下各自的优点/缺点吗?

java unit-testing

20
推荐指数
3
解决办法
2万
查看次数

使用nolock进行Java Hibernate HQL查询

有没有办法运行这些查询,好像我添加了一个(NOLOCK)提示?

java orm hibernate nolock

10
推荐指数
2
解决办法
2万
查看次数

标签 统计

java ×2

c# ×1

generics ×1

hibernate ×1

methods ×1

nolock ×1

orm ×1

unit-testing ×1