C#从文本框中获取字符串 [英] C# get string from textbox

查看:1777
本文介绍了C#从文本框中获取字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我在这里有一个要求登录细节的表单。它有两个文本框:
$ b


  1. 用户名

  2. 密码

  3. ol>

    我想要的是 获取在该文本字段中输入的字符串。



    我还不熟悉C#中的方法..(在java中,使用了getString方法)。在C#中,等价方法是什么?

    解决方案

    在C#中,与java不同,我们不必使用任何方法。 TextBox属性 Text 用于获取或设置文本。



    获取

     字符串用户名= txtusername.Text; 
    字符串密码= txtpassword.Text;

    设置

      txtusername.Text =my_username; 
    txtpassword.Text =12345;


    I am just a noob in C#, and I've got this question to ask you.

    I have here a form that asks for login details. It has two textfields:

    1. Username
    2. Password

    What I want is to get the strings entered in that textfields.

    I am not yet familiar with the methods in C#..(in java, getString method is used). What could be the "equivalent" method here in C#?

    解决方案

    In C#, unlike java we do not have to use any method. TextBox property Text is used to get or set its text.

    Get

    string username = txtusername.Text;
    string password = txtpassword.Text;
    

    Set

    txtusername.Text = "my_username";
    txtpassword.Text = "12345";
    

    这篇关于C#从文本框中获取字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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