c#编码的解释 [英] explanation for c# coding
问题描述
我需要逐行解释以下编码。请尽快请求发送解决方案。
I need line by line explanation for following codings.kindly request to send the solution as early as possible.
namespace RunTimeDefenceAgainstCodeInjectionAttack
{
static class genModule
{
public static SqlConnection con =
new SqlConnection("server=.;uid=sa;database=RunTimeDefenceAgainstCodeInjectionAttack");
//public con As New OleDbConnection("Server=.;database=OnFairness;user id=sa;password=")
public static SqlCommand cmd = new SqlCommand("", con);
//public static bool startmonitor = false;
}
}
推荐答案
// Identify the namespace for this code module
namespace RunTimeDefenceAgainstCodeInjectionAttack
{
// Create a static class with the name genModule
static class genModule
{
// Create a SqlConnection object to connection to the "RunTimeDefenceAgainstCodeInjectionAttack" database.
public static SqlConnection con =
new SqlConnection("server=.;uid=sa;database=RunTimeDefenceAgainstCodeInjectionAttack");
//This line is commented out and will not be compiled.
//public con As New OleDbConnection("Server=.;database=OnFairness;user id=sa;password=")
// Create a SqlCommand object that can be used to generate and execute queries against the connection "con" which was created above.
public static SqlCommand cmd = new SqlCommand("", con);
//This line is commented out and will not be compiled.
//public static bool startmonitor = false;
}
}
在连接字符串上:
On the connection string:
"server=.;uid=sa;database=RunTimeDefenceAgainstCodeInjectionAttack"
sever =。
表示服务器在本地计算机上。
uid = sa
意味着用户ID是 sa
,这也意味着您没有使用类似Windows身份验证的东西,而是使用数据库身份验证
database = RunTimeDefenceAgainstCodeInjectionAttack
表示指定的数据库名称是 RunTimeDefenceAgainstCodeInjectionAttack
要查看所有连接字符串属性的说明,请转到 http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.connectionstring.aspx [ ^ ]
The sever=.
means that the server is on the local machine.
The uid=sa
means that the user id is sa
, which also mean that you are not using something like Windows authentication, but using the database authentication
The database=RunTimeDefenceAgainstCodeInjectionAttack
means that the database name that is specified is RunTimeDefenceAgainstCodeInjectionAttack
To see description of all connection string attributes goto http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.connectionstring.aspx[^]
private static List MapList(DataTable dt)
{
List list = new List();
FieldInfo[] fields = typeof(T).GetFields();
T t = Activator.CreateInstance();
foreach (DataRow dr in dt.Rows)
{
foreach (FieldInfo fi in fields)
fi.SetValueDirect(__makeref(t), dr[fi.Name]);
list.Add(t);
}
return list;
}
任何人都可以向我解释上面的代码..
Can anyone please explain me the above code..
这篇关于c#编码的解释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!