我正在尝试添加1到我的变量,sum但编译器说
变量
sum未分配
在我的if语句中.我试过移动它,但无论我做什么,变量仍然是未分配的.
static void Main()
{
int sum;
if(true)
{
sum += 1;
}
Console.Write(sum);
Console.ReadKey();
}
Run Code Online (Sandbox Code Playgroud)
如何更改我的代码来修复此错误并停止编译器抱怨?
我有"用户"表
id int
username varchar(40)
joindate date
email varchar(60)
password nvarchar(100)
Run Code Online (Sandbox Code Playgroud)
我想执行以下查询
INSERT INTO User (username, joinDate, email, password)
VALUES ('Kristian', '15/11/2017', 'foo@outlook.com', 'password')
Run Code Online (Sandbox Code Playgroud)
SQL Server 2014引发错误
关键字'User'附近的语法不正确
我究竟做错了什么?
当我在我的 cshtml 页面中单击图像的某个部分时,我想执行一些 javascript 函数。但是,可点击区域不会出现。
我也不想引用 www.google.com,但它要求我具有 alt 和 href 属性。
为什么我的代码不起作用?
这是我的代码:
<image src="~/Content/Images/PeriodicTable2.jpg" width="900" height="450" alt="Sample Image" />
<map name="PeriodicTable">
<area shape="rect" coords="0,0,200,200" onclick="Popup('Hydrogen')" href="https://www.google.com" alt="something">
</map>
Run Code Online (Sandbox Code Playgroud) 我想创建一个触发器,当我在A列中插入一个字符串时,一个较短的版本(最多117个字符)被插入到B列中,两者都在同一个表中.
我如何使用SQL Server 2014执行此操作?
这是我的代码:
private void button1_Click(object sender, EventArgs e)
{
var api = RiotApi.GetInstance("KEY");
try
{
var game = api.GetCurrentGame(RiotSharp.Platform.EUW1, 79200188);
}
catch (RiotSharpException ex)
{
throw;
}
foreach (var player in game.Participants) // Can't find game variable
{
}
}
Run Code Online (Sandbox Code Playgroud)
我不能在我的foreach循环中调用game.Participants,因为我在try语句中初始化游戏.我不能在try语句之外初始化游戏,因为要做到这一点我必须给它一个临时值,我不知道它将是什么样的价值.
有没有办法将变量声明为null?或者可能有不同的方法来解决这个问题?