Display first (n) number of words of string......
-
Hi, I have a string of text of random length but need to display only the first 250 characters (preferably whole words), in a label. Any remaining words would be displayed in a seperate label. Please can someone give me advice on what i need to do or at least the methodology i need to look into. Many Thanks!
-
Hi, I have a string of text of random length but need to display only the first 250 characters (preferably whole words), in a label. Any remaining words would be displayed in a seperate label. Please can someone give me advice on what i need to do or at least the methodology i need to look into. Many Thanks!
hey dear it is basics of strings. try to use substring function of string e.g: string strtext; printf(strtext.substring(0,250)); this give u a result.
Hello Forum Always be in touch to help about the topic ASP.NET
-
hey dear it is basics of strings. try to use substring function of string e.g: string strtext; printf(strtext.substring(0,250)); this give u a result.
Hello Forum Always be in touch to help about the topic ASP.NET
Thanks! I knew it was basic, but havent used it for soo long! I was having one of those times when trying to remember just made it harder to think clearly. ;-) Thanks for the reply!!!!
-
Hi, I have a string of text of random length but need to display only the first 250 characters (preferably whole words), in a label. Any remaining words would be displayed in a seperate label. Please can someone give me advice on what i need to do or at least the methodology i need to look into. Many Thanks!
Use str.LastIndexOf(' ', 250) to find the space closest to the 250th character. If it finds one reasonably close to 250, use str.Substring to get the part of the string up to the space. Otherwise you just have to cut the string at 250 anyway.
Experience is the sum of all the mistakes you have done.