c# - 如何将int变量转换为字符串变量
问题描述
我目前正在从用户将填写三个数字的文本框中拆分一个字符串。我想将这些数字保存为单独的整数。关于如何做到这一点的任何帮助?谢谢你的帮助!
string[] count = txtPoemInput.Text.Split('/'); //Splitting values for keyword numbers
int Poem, Line, Word;
count[0] = Poem.ToString; // Example
count[1] = Line; // Example
count[2] = Word;
解决方案
这是您需要做的。使用 Convert.ToInt32
Poem = Convert.ToInt32(count[0]);
Line = Convert.ToInt32(count[1]);
Word = Convert.ToInt32(count[2]);
推荐阅读
- google-apps-script - 如何在 Google 表格中的图表上创建多个图形?
- c# - 将 JSON 响应转换为 Graph.EducationAssignment 对象
- ios - SecItemCopyMatching 始终为存储的 EC 密钥返回“似乎不是有效的钥匙串项”
- c - 如何包含 Apache Avro C 头文件?
- unity3d - NullReferenceException 在 Unity 中使用 ScriptableObjects
- postgresql - 仅在 Linux 中;org.postgresql.util.PSQLException:错误:关系“table_name”不存在
- flutter - 颤动改变焦点上的边框颜色
- python - 在python中循环列名
- python - 如何获取文件大小而不在python请求中下载它
- dictionary - 有没有办法将 Tableau 中的地理数据点分配给所有未指定的区域?