我正在使用c#
我的变量中有以下字符串.
string results = "Mr,Mike,Lewis,32,Project Manager,India";
Run Code Online (Sandbox Code Playgroud)
现在我想在会话变量的Dictionary类型中添加这些值.我在代码中声明了一个dict类型变量.
Dictionary<string, string> skywardsDetails = new Dictionary<string, string>();
Run Code Online (Sandbox Code Playgroud)
现在写下我编写的代码如下:
if (!string.IsNullOrEmpty(results))
{
string[] array = results.Split(',');
string title = array[0];
string firstname = array[1];
string lastname = array[2];
string age = array[3];
string designation = array[4];
string country = array[4];
//Here I want to write the new code which will add the results.Split(',') values in my Session variable as a Dictionary type.
foreach (string key in results.Split(','))
{
skywardsDetails.Add(key,//What to do here)
} …Run Code Online (Sandbox Code Playgroud) 我有一个特定的SQL查询:
SELECT TOP 20 * FROM tblIm WHERE Id NOT IN (SELECT TOP 20 Id FROM tblIm)
Run Code Online (Sandbox Code Playgroud)
我刚试过这个:
var results = from myRow in Ds.AsEnumerable().Take(minRecords)
where myRow.Field<int>("Trail_Id") > 1
&& myRow.Field<int>("Id") <= 20
select myRow;
Run Code Online (Sandbox Code Playgroud)
但它并不像我想要的那样工作.那么如何将其转换为类似于SQL语句的LINQ语句呢?
有什么建议?
谢谢大家但我终于得到了解决方案:
var testresult = from c in Ds.AsEnumerable().Take(20)
where !(from o in Ds.AsEnumerable().Take(intSkip)
select o)
.Contains(c)
select c;
Run Code Online (Sandbox Code Playgroud) 我必须从包含下表的html网页中提取一些信息:
//Http://www.example.com/12.html
//<html ... >
<table>
<tr>
<td>HIIIIIIIIIII</td> // this is what I need from this page
</tr>
<tr><td>bla bla bla</td></tr>
</table>
Run Code Online (Sandbox Code Playgroud)
有任何想法吗 ?
感谢你
我在第5行收到错误,listCell.Count()尝试使用listCell.Items.Count()解决它,但这不起作用......任何想法?错误:不包含count的定义.
int listCellCounter = 0;
for (int x = 0; x < listId.Items.Count; x++)
{
Console.WriteLine("something " + listId.Items[x] + " " + listCell.Items[listCellCounter]);
if (listCellCounter == listCell.Count() - 1)
{
listCellCounter = 0;
}
else
{
listCellCounter += 1;
}
}
Run Code Online (Sandbox Code Playgroud) 我有3个内插a,b,c,它们的值分别为2,4,5 ..如何array int[] stats = new int[3];在c中存储3个数字#
我必须将该值添加到字符串,输出应该是
string val = [2,4,5];
我想加密一个id并传递给一个链接...例如
id=196
encryptedid=345
randno=234
encryptedrandno=456
id=encryptedid+encryptedrandno
link: id
so when user clikcs that link at backend
id=id-encryptedrandno(which gives us encryptedid)
id=decrypt(id)
Run Code Online (Sandbox Code Playgroud)
请告诉我这个逻辑,我正在使用c#web应用程序
public class c2
{
public void Print()
{
MessageBox.Show("C2");
}//print
}//c2
public class c1 : c2
{
public void Print()
{
MessageBox.Show("C1");
}//print
}//c1
Run Code Online (Sandbox Code Playgroud)
如何使用派生类Object调用基类(c2)的Print()(函数名在两个类中都相同)
我有一个richTextBox1与此行:
my test
my test2
Run Code Online (Sandbox Code Playgroud)
并尝试使用此代码将行插入到列表框或combox中:
richTextBox1.Text = File.ReadAllText(@"New ID.txt").ToString();
listBox1.Items.Add(richTextBox1.Text);
Run Code Online (Sandbox Code Playgroud)
但显示列表框
mytestmytest2
如何将每个项目插入(附加)为新行?
我这样做:
long[] HistogramValues = Form1.GetHistogram(bitmap);
Form1.Histograms.AddRange(HistogramValues);
Run Code Online (Sandbox Code Playgroud)
但是,直方图还包含256个值,如HistogramValues.我希望在索引[0]的直方图中,将有来自HistogramValues的256个值,然后在[1]中还有256个值,然后是[2],依此类推.
直方图是一个列表