小编aka*_*ari的帖子

在C#中的类属性中使用<T>声明

我有这样的课

public class Tbl
{
    public string Name {get; set}
    public anyClass Datasource {get; set;} //I don't know what to use there
}

//Usage:
List<anyClass> anyList = GetList(); // Assuming I had a list
Tbl Table = new Tbl();
Table.Name = "Table1";
Table.Datasource = anyList;
Run Code Online (Sandbox Code Playgroud)

在这里,我的问题是使数据源可以接受任何输入类.如何以正确的方式声明Tbl类的数据源?

非常感谢

c#

5
推荐指数
1
解决办法
1305
查看次数

查询C#中另一个列表中的列表

我有一个这样的课

public class Tbl
{
    public List<Row> Rows {get; set;}
}
public class Row
{
    public string Name {get; set;}
    public Value {get; set;}
}
//Using the class  
//Add rows to Tbl
Tbl t = new Tbl();
t.Rows.Add(new Row() {Name = "Row1", Value = "Row1Value"};
t.Rows.Add(new Row() {Name = "Row2", Value = "Row2Value"};
t.Rows.Add(new Row() {Name = "Row3", Value = "Row3Value"};

//Now I want to select the Row2 in this list, usually, I use this way
public Row GetRow(this Tbl …
Run Code Online (Sandbox Code Playgroud)

c#

4
推荐指数
1
解决办法
161
查看次数

如何在C#中声明要使用的变量["name1"]

我想在C#中声明一个这样的变量

public anyType variable;
Run Code Online (Sandbox Code Playgroud)

然后我可以像这样使用它

variable["name1"] = anyValue1;
variable["name2"] = anyValue2;
Run Code Online (Sandbox Code Playgroud)

我找不到任何解决方案来声明使用哪种类型的变量.
请帮我.

我感谢任何评论


附加信息:我有一节课:

public class Template
{
    public string Name {get; set; }
    public string Content {get; set;}
}
Run Code Online (Sandbox Code Playgroud)

我想像这样设置模板内容和模板名称的值

Template t = new Template();
t["Name"] = "template1";
t["Content"] = "templatecontent1";
Run Code Online (Sandbox Code Playgroud)

不:

Template t = new Template();
t.Name = "template1";
t.Content = "templatecontent1";
Run Code Online (Sandbox Code Playgroud)

我的意思是像一个表属性.这里我有表格模板,它有2列名称和内容.这样我就可以查询Template ["Name"]和Template ["Content"]
谢谢

c#

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

ASP.NET MVC2中的文件夹结构

我有MVC2的文件夹结构的问题

我怎么能用这种方式:
文件夹:
控制器
--Portal
----会计
------ CashController.cs
------ BankController.cs
---- HR
------ EmployeesController.cs模型
视图
--Portal
----会计
------现金
-------- Index.aspx
-------- List.aspx
------银行
---- ---- Index.aspx
------ HR
-------- Index.aspx
-------- Employee.aspx

我该如何使用这样的文件夹结构,如何使用正确的表单路由URL.

非常感谢

asp.net-mvc-2

1
推荐指数
1
解决办法
239
查看次数

标签 统计

c# ×3

asp.net-mvc-2 ×1