我正在尝试在C#Winforms中运行以下代码段.这段代码适用于pgsql 2.2.6适配器.为了与pgsql3.0.5适配器一起正常工作,可以进行哪些更正?谢谢.
NpgsqlConnection conn = new NpgsqlConnection(MainForm2.MyConString);
{
conn.Open();
using (NpgsqlCommand cmd = new NpgsqlCommand("SELECT rfid,name,sc_id from passenger ORDER by name", conn))
{
NpgsqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
var obj = new PassengerClass
{
RFID = dr.GetString(0),
Name = dr.GetString(1),
sc_id = dr.GetInt32(2)
};
s = dr.GetString(0);
try { ret.Add(s, obj); }
catch (Exception ex) { SM.Debug("Fail to add RFID Name in hash RFID:" + s + ex.ToString()); }
}
}
MainForm2.PassHash = ret;
try
{
using (NpgsqlCommand …Run Code Online (Sandbox Code Playgroud) 以下2个C#片段之间的执行存在差异吗?
do
{
Console.WriteLine(x.ToString());
++x;
}
while (x < 7);
Run Code Online (Sandbox Code Playgroud)
和
label:
{
Console.WriteLine(x.ToString());
++x;
}
if (x < 7) goto label;
Run Code Online (Sandbox Code Playgroud)
我想弄清楚为什么这么糟糕.谢谢.
编辑:如果我添加括号,片段非常相似.
EDIT2:在Visual Studio中,我点击了Go to Disassembly,我得到以下代码:
do
{
00000037 nop
Console.WriteLine(x.ToString());
00000038 lea ecx,[ebp-40h]
0000003b call 63129C98
00000040 mov dword ptr [ebp-48h],eax
00000043 mov ecx,dword ptr [ebp-48h]
00000046 call 63148168
0000004b nop
++x;
0000004c inc dword ptr [ebp-40h]
}
0000004f nop
while (x < 7);
00000050 cmp dword ptr [ebp-40h],7
00000054 setl al
00000057 movzx eax,al
0000005a mov …Run Code Online (Sandbox Code Playgroud)