我有我已經宣佈枚舉如下命名空間枚舉名稱:自定義組合框
namespace IXMSoft.Business.SDK.Data
{
using System;
public enum BaudRate
{
BR115200 = 7,
BR19200 = 4,
BR230400 = 8,
BR2400 = 1,
BR38400 = 5,
BR4800 = 2,
BR57600 = 6,
BR9600 = 3
}
}
當我取回在組合框中,這是另一個命名空間這些值,使用語句
comboBox1.Items.Add(BaudRate.BR5700);
它示出了該值作爲例如
「BR5700」
我想remove BR in front and just want to display the value as "5700"
。 我該怎麼辦?
需要使用'替換'mmethod – Rahul
獲取字符串,然後將其添加到ComboBox1.String str = BaudRate.BR5700;如果(str.contains(「BR」))str = str.replace(「BR」,「」);希望它可以幫助你。 – MahaSwetha
@MahaSwetha謝謝! :) –