Reputation: 133
I want to Remove string Characters if string is more than varchar(255) length and save that in database in c#
I am not able to find any solution .
string test.RatingItemName="hshhhdhhdshdsdsddssdsdsghdsh";
if (test.RatingItemName > varchar(255))
{
//trim the extra characters after varchar(255)
}
Upvotes: 1
Views: 2442
Reputation: 14389
Simply use substring
. Try like:
string test.RatingItemName="hshhhdhhdshdsdsddssdsdsghdsh";
if(test.RatingItemName.Length>255)
{
test = test.RatingItemName.Substring(0,255);
}
Upvotes: 6