组合框返回“文本" [英] combobox return with 'text'

查看:87
本文介绍了组合框返回“文本"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在查询中使用combobox.selecteditem,它在引号中返回TEXT表示"TEXT",但我需要不带引号的TEXT.

i use combobox.selecteditem in query, it return TEXT in quote mean "TEXT" but i need it without Quote as TEXT.

推荐答案

在C#中使用双引号用于包围string literals.因此,这里"TEXT"是字符串文字.当将此字符串写入UI或打印到输出介质(例如Report 或a File.)时,双引号将不会出现,例如
In C# double quotes are used to enclose string literals. So here "TEXT" is a string literal. The double quotes will not appear when this string is written to UI or printed to an out put medium say Report or a File. eg.
Label1.Text = "TEXT";
System.IO.File.WriteAllText(fileName,"TEXT");


如果删除了双引号,则它将表示一个variable ,它可以保存原始数据类型或对象的值,该对象可以是struct或class等的实例.


If the double quotes are removed then it will represent a variable which can hold the value of premitive data type or an object which may be an instance of struct or class etc.

var TEXT = "This is text";
var TEXT = new MyClass();


如果您的要求是使用返回的string value作为variable ,则Reflection 可能会有所帮助,并且这些文章
反射(C#编程指南) [ .NET中的反射 [ C#教程中的反思 [


If your requirement is to use the string value returned as a variable then the Reflection may be helpful and these articles
Reflection (C# Programming Guide)[^]
Reflection in .NET[^]
Reflection in C# Tutorial[^]
may be helpful.


这篇关于组合框返回“文本"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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