Actually I convert this code into C#...
Function getpatcode()
Dim some = TextBox13.Text
Dim another As Integer
Dim newslip2 As String = "pat-0"
Dim number As String
another = CInt(some.TrimStart("p", "a", "t", "-"))
another += 1
number = another.ToString()
Return newslip2 + number
End Function
public object getpatcode()
{
dynamic some = TextBox13.Text;
int another = 0;
string newslip2 = "pat-0";
string number = null;
another = Convert.ToInt32(some.TrimStart("p", "a", "t", "-"));
another += 1;
number = another.ToString();
return newslip2 + number;
}
But some errors found.. Can anyone check this code?
Regards,
Loading

Posted May 17, 2011, 11:18 PM EDT
Kindly try the below code and let me know,still you have an issues.
public object getpatcode()
{
dynamic some = TextBox13.Text;
int another = 0;
string newslip2 = "pat-0";
string number = "";
another = Convert.ToInt32(some.TrimStart("p", "a", "t", "-"));
another += 1;
number = another.ToString();
return newslip2 + number;
}
Ankit NandekarRank #703 · 3.4K reputationPosted May 17, 2011, 11:23 PM EDT
Mayur GujrathiRank #666 · 3.6K reputationPosted May 17, 2011, 11:53 PM EDT
link for code converter
you can do various things here
Veeramanikandan Dhanabalan20 reputationPosted May 18, 2011, 12:06 AM EDT
When I execute I got this error
Input string was not in a correct format....
private object getId()
{
string some = textBox1.Text;
int another = 0;
string newslip2 = "CSE-0";
string number = null;
another = Convert.ToInt32((some.TrimStart(new char[] { "C", "S", "E", "-" })));
another += 1;
number = another.ToString();
return newslip2 + number;
}
Mayur GujrathiRank #666 · 3.6K reputationPosted May 18, 2011, 12:10 AM EDT
Posted May 18, 2011, 12:11 AM EDT
can you try this line.
another = Convert.ToInt32((some.TrimStart(new char[] { 'C', 'S', 'E', '-' })));
VulpesRank #55 · 29.2K reputationPosted May 18, 2011, 2:44 AM EDT
dynamic some = TextBox13.Text;
just use:
string some = TextBox13.Text;
Although the first line works, it pulls in the dynamic language runtime (DLR) and then uses late binding to determine the type of 'some'. This is unnecessary and just slows down the code.
fawzan mohamed65 reputationPosted May 19, 2011, 2:18 AM EDT
public object getpatcode()
{
dynamic some = TextBox13.Text;
int another = 0;
string newslip2 = "pat-0";
string number = null;
another = Convert.ToInt32(some.TrimStart('p', 'a', 't', '-'));
another += 1; number = another.ToString();
return newslip2 + number;
}
Suthish NairRank #92 · 22.8K reputationPosted May 19, 2011, 2:53 AM EDT