about Separate string by ","

Stimulsoft Reports.NET discussion
Post Reply
Matt
Posts: 3
Joined: Tue Feb 14, 2012 2:08 am
Location: china

about Separate string by ","

Post by Matt »

how to get the count of a string Separate by “,” ? For example

"abc,off,kl,mell" Separate by "," and get the count , the result is 4!!!!

thanks

matt:kiss:
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

about Separate string by ","

Post by HighAley »

Hello, Matt.
Matt wrote:how to get the count of a string Separate by “,” ? For example
"abc,off,kl,mell" Separate by "," and get the count , the result is 4!!!!
Please add next code to the Code tab before auto generated code.

Code: Select all

public int SplitByCommaLength(string st)
{
    return  st.Split(new char[] {','}).Length;
}
Then you could use next expression in your report:

Code: Select all

{SplitByCommaLength("abc,off,kl,mell")}
Thank you.
Post Reply