如何编写一个前50个字符并丢弃其余字符的文本框语句? [英] How do I write a textbox statement that takes the first 50 characters and discards the rest?

查看:66
本文介绍了如何编写一个前50个字符并丢弃其余字符的文本框语句?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何编写一个前50个字符并丢弃其余字符的文本框语句?

How do I write a textbox statement that takes the first 50 characters and discards the rest?

User = TextBox1.Text.Substring(0, 50)



错误代码:


Error Code:

Index and length must refer to a location within the string.
Parameter name: length

推荐答案

在查找子字符串之前,请检查原始字符串( TextBox1.Text )长度已经小于或等于所需的长度。

你可以通过思考一下,阅读原始帮助页面或最简单的实验来弄清楚这一点。如果你要在每个简单的问题上提出这样的问题,你就永远不会成为初学者。你需要开始。



-SA
Before finding a substring, check up if the original string (TextBox1.Text) length is already less or equal to the required length.
You could figure out this by thinking just a bit, reading original help page or simplest experiment. If you are going to ask such question on each simple problem, you will never become even the beginner. You need to begin.

—SA


这篇关于如何编写一个前50个字符并丢弃其余字符的文本框语句?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆