如何使用 Visual Studio C# 在 SharePoint 中划分两个字段

How Can I Divide Two Field In SharePoint With Visual Studio C#

我想使用 visual studio c# 在 SharePoint 中划分 2 个字段。我有如下所示的代码

SPView vw = jobDef.View["All items"];
vW.ViewFields.Add("MinSalary");
vW.ViewFields.Add("MaxSalary");
vW.ViewFields.Add("AvgSalary");
vw.InLineEdit = "TRUE";
vw.update();


SPListItem newDef;
newDef = jobDef.Items.Add();
newDef["MinSalary"] = "40000";
newDef["MaxSalary"] = "80000";
newDef["AvgSalary"] = int.Parse("MaxSalary")/ int.Parse(MinSalary); // i dont know how what to do here

有人帮帮我吗!

我不能 100% 确定这是否是您想要做的。但您可以尝试以下操作:

int avgSalary = Convert.ToInt32(newDef["MaxSalary"]) / Convert.ToInt32(newDef["MinSalary"]);
newDef["AvgSalary"] = avgSalary.ToString();