在我们的一个项目中,我们有类似的代码.任何人都可以解释(简单英语)为什么需要修复语句?
class TestClass
{
int iMyVariable;
static void Main()
{
TestClass oTestClass = new TestClass();
unsafe
{
fixed (int* p = &oTestClasst.iMyVariable)
{
*p = 9;
}
}
}
}
Run Code Online (Sandbox Code Playgroud) 在C#.net中,我有以下DataSource设置,我试图在后面的代码中动态分配WHERE子句...
<asp:LinqDataSource ID="LinqDataSource1" runat="server"
ContextTypeName="MyNameSpace.DataClasses1DataContext"
TableName="MyTableWithADateTimeColumn" >
</asp:LinqDataSource>
Run Code Online (Sandbox Code Playgroud)
背后的代码看起来像这样......
LinqDataSource1.Where = "MyDateColumn == DateTime(" + DateTime.Now + ")";
Run Code Online (Sandbox Code Playgroud)
这给了我一个错误')' or ',' expected.我也试过把它放在引号内,因为没有把它作为DateTime和引号标记......
LinqDataSource1.Where = @"MyDateColumn == """ + DateTime.Now + @""" ";
Run Code Online (Sandbox Code Playgroud)
这给了我Operator '==' incompatible with operand types 'DateTime' and 'String'.我已经尝试了其他几种方法,但我显然在这里遗漏了一些东西.
类似的代码适用于字符串.