组合框返回“文本" [英] combobox return with 'text'
问题描述
我在查询中使用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
或aFile.
)时,双引号将不会出现,例如
In C# double quotes are used to enclosestring literals
. So here"TEXT"
is a string literal. The double quotes will not appear when this string is written toUI
or printed to an out put medium sayReport
or aFile.
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屋!