正如我在阅读有关GC的3本书时,我注意到一些奇怪的事实:
C#通过CLR
CriticalFinalizerObject:CLR以非常特殊的方式处理此类和从中派生的类

什么 ???
"没有找到足够的内存来编译方法? "恕我直言 - 代码应该已经编译了......不是吗?
当我编写c#代码时 - 整个代码在运行之前被编译为IL ...不是吗?但根据文本 - 在RUNTIME - 他可能发现编译的内存不足 ......
救命 ?
我有两个日期作为整数.如何在c#中找到这两个整数之间的月份差异?
例如:
Int32 beginDate= 20130307(yyyymmdd)
Int32 beginDate= 20140507(yyyymmdd)
Run Code Online (Sandbox Code Playgroud)
我需要14个月的结果.
我已经尝试过了:
DateTime beginDatepar = Convert.ToDateTime(beginDate);
DateTime endDatepar = Convert.ToDateTime(beginDate);
int monthDifference = ((beginDatepar.Year - endDatepar.Year) * 12) +
beginDatepar.Month - endDatepar.Month;
Run Code Online (Sandbox Code Playgroud)
但是当我将Int32转换为Datetime时,错误是"从'Int32'到'DateTime'的无效转换"
我想用asp.net从SQL数据库中检索二进制数据.但是输出中显示的数据与我插入的数据不匹配.这是我的代码:
string EQuery = "SELECT * FROM Ph_Tbl_Contacts WHERE (Contact_ID =" + Contact_ID + ")";
DataSet DSs = new DataSet();
DataTable dt = new DataTable();
DataRow dr = dt.NewRow();
DSs = DB.ExecuteQueryData(EQuery);
dt = DSs.Tables[0];
// dr = dt.NewRow();
dr = dt.Rows[0];
byte[] pic;
byte[] raw = (byte[])dr["Contact_CardImage"];
// Session[OpenDialog.STORED_IMAGE] = raw ;
Run Code Online (Sandbox Code Playgroud)
这是插入部分:
byte[] IMAGEbYTE ;
IMAGEbYTE = (byte[])(Session["SessionImage"]);
string Query = "INSERT INTO Ph_Tbl_Contacts (Contact_Name, Contact_LName, " +
"Contact_Company, Contact_Email, Contact_Tel, " +
"Contact_Mobile,Contact_CardImage,Is_Public,User_ID,Save_Date)" +
"VALUES (N'" + …Run Code Online (Sandbox Code Playgroud) 4200 Syntax Error当我为MS Access数据库执行此代码时,我得到:
protected void Button1_Click(object sender, EventArgs e)
{
using (OdbcConnection conn = new OdbcConnection(@"Dsn=ani;dbq=D:\anita\inventory\chemicals.accdb;defaultdir=D:\anita\inventory;driverid=25;fil=MS Access;maxbuffersize=2048;pagetimeout=5;uid=admin"))
{
conn.Open();
string CommandText = "INSERT INTO SupplierDetails (ID, Supplier, Company, Address, State, Country, Pincode, PhoneNo, MobileNo, Email, Fax, RawMaterials, Note) VALUES (@ID, @Supplier, @Company, @Address, @State, @Country, @Pincode, @PhoneNo, @MobileNo, @Email, @Fax, @RawMaterials, @Note)";
using (OdbcCommand cmd = new OdbcCommand(CommandText, conn))
{
cmd.Parameters.AddWithValue("@ID", TextBox3.Text);
cmd.Parameters.AddWithValue("@Supplier", TextBox4.Text);
cmd.Parameters.AddWithValue("@Company", TextBox1.Text);
cmd.Parameters.AddWithValue("@Address", TextBox11.Text);
cmd.Parameters.AddWithValue("@State", TextBox2.Text);
cmd.Parameters.AddWithValue("@Country", TextBox5.Text);
cmd.Parameters.AddWithValue("@Pincode", TextBox10.Text);
cmd.Parameters.AddWithValue("@PhoneNo", TextBox6.Text);
cmd.Parameters.AddWithValue("@MobileNo", TextBox7.Text); …Run Code Online (Sandbox Code Playgroud) private string DoStuff(object result, StringBuilder returnBuilder)
{
// get a list of all public properties and order by name
// so we can guarentee that the order of the headers and
// the results are the same
foreach (var prop in result.GetType().GetProperties().OrderBy(x => x.Name))
{
// do something cool
}
}
Run Code Online (Sandbox Code Playgroud)
我的问题是,如果没有OrderBy在for循环中我保证List的本机顺序将是在对象中声明属性的顺序
我正在处理Windows窗体.我面临着非常奇怪的问题.
在其中一个按钮事件处理程序中,我已经应用了if和else条件.
问题是如果执行条件和条件.
有人能指出我错在哪里吗?
private void button1_Click(object sender, EventArgs e)
{
if (radioButton1.Checked == true && checkEbayName(textBox1.Text) == true )
{
DataSet ds = GetUserByEbayName(textBox1.Text);
if (ds == null)
{
return;
}
dataGridView1.DataSource = ds.Tables["Customer"];
}
if (radioButton2.Checked == true && checkName(textBox1.Text) == true)
{
DataSet ds = GetUserByName(textBox1.Text);
//if (checkCustomer(textBox1.Text, textBox2.Text) == true)
//{
if (ds == null)
{
return;
}
dataGridView1.DataSource = ds.Tables["Customer"];
}
else
{
MessageBox.Show("No Customer with matching details");
}
}
Run Code Online (Sandbox Code Playgroud) c# ×5
asp.net ×2
.net ×1
.net-4.0 ×1
clr ×1
datetime ×1
if-statement ×1
image ×1
int32 ×1
linq ×1
ms-access ×1
reflection ×1
sql ×1
sql-server ×1
winforms ×1