hello friend
here is my code...string l = dataGridView1[4, a].Value.ToString();
if (l == "Opening Sauda")
{
trantype11 = "O";
}
else if (l == "Percentage Wise")
{
trantype11 = "P";
}
else if (l == "Transation")
{
trantype11 = "T";
}
if datagrid view cell cantain string like Percentage Wise
than trentype11 sholud set forst charector p
like
i try it but no working(it give last character e but i want p )
string b = dataGridView1[1, a].Value.ToString();
broktype11= b.Substring(1, 1);
解决方案
Don''t use substring, use simply char first = b[0]. If by some strange reason you need a string containing this one char, it would be string oneChar = new string(first, 1). That''s it.
—SA
Try string b = dataGridView1[1, a].Value.ToString();
broktype11= b.Substring(0, 1);
If you want the first character in a string use .Substring(0,1) - not .Substring(1,1).