C# 向字典追加新值
我有以下字典:C# 向字典追加新值,c#,dictionary,C#,Dictionary,我有以下字典: Dictionary<string, Value> DictFoundExpected = new Dictionary<string, Value>(); public struct Value { string code; int found; int expected; public Value(int f,int exp
Dictionary<string, Value> DictFoundExpected = new Dictionary<string, Value>();
public struct Value
{
string code;
int found;
int expected;
public Value(int f,int exp,string code)
{
this.found=f;
this.expected=exp;
this.code = code;
}
}
我被困在如何增加value的值上。预期值为
我被困在如何增加价值的价值上
只需将一个方法添加到您的结构值
,该方法会增加值。预期的
类似:
public struct Value
{
string code;
int found;
int expected;
public void IncreaseExpected()
{
expected++;
}
public Value(int f, int exp, string code)
{
this.found = f;
this.expected = exp;
this.code = code;
}
}
然后像这样使用它(我稍微更改了代码,只读取sqlreader字段一次):
我被困在如何增加价值的价值上
只需将一个方法添加到您的结构值
,该方法会增加值。预期的
类似:
public struct Value
{
string code;
int found;
int expected;
public void IncreaseExpected()
{
expected++;
}
public Value(int f, int exp, string code)
{
this.found = f;
this.expected = exp;
this.code = code;
}
}
然后像这样使用它(我稍微更改了代码,只读取sqlreader字段一次):
我被困在如何增加价值的价值上
只需将一个方法添加到您的结构值
,该方法会增加值。预期的
类似:
public struct Value
{
string code;
int found;
int expected;
public void IncreaseExpected()
{
expected++;
}
public Value(int f, int exp, string code)
{
this.found = f;
this.expected = exp;
this.code = code;
}
}
然后像这样使用它(我稍微更改了代码,只读取sqlreader字段一次):
我被困在如何增加价值的价值上
只需将一个方法添加到您的结构值
,该方法会增加值。预期的
类似:
public struct Value
{
string code;
int found;
int expected;
public void IncreaseExpected()
{
expected++;
}
public Value(int f, int exp, string code)
{
this.found = f;
this.expected = exp;
this.code = code;
}
}
然后像这样使用它(我稍微更改了代码,只读取sqlreader字段一次):
这是假设您的值结构具有如下属性:
public int Found { get { return found; } }
public int Expected { get { return expected; } }
public string Code { get { return code; } }
这是假设您的值结构具有如下属性:
public int Found { get { return found; } }
public int Expected { get { return expected; } }
public string Code { get { return code; } }
这是假设您的值结构具有如下属性:
public int Found { get { return found; } }
public int Expected { get { return expected; } }
public string Code { get { return code; } }
这是假设您的值结构具有如下属性:
public int Found { get { return found; } }
public int Expected { get { return expected; } }
public string Code { get { return code; } }
谢谢你的回答,我投了赞成票但我更喜欢丹尼斯方法谢谢你的回答,我投了反对票但我更喜欢丹尼斯方法谢谢你的回答,我投了反对票但我更喜欢丹尼斯方法谢谢你的回答,我投了反对票但我更喜欢丹尼斯方法