我正在使用visual studio 11.0和.Net網絡編程我想將字符串inputed從TextBox1轉換爲TitleCase,sententenceCase, UpperCase和小寫,從RadioButtonList1中選擇並在Label1.Text中顯示結果。但我不希望我的單詞在引號內被轉換。例如「ASP.NET」,「Ph.D」和「xyz」 我已經完成了標題大寫,大寫和小寫的編碼,但是我希望這個代碼在無論「quites」出現時都被忽略/跳過或者過濾。將字符串轉換爲TitleCase,SentenceCase,UpperCase和LowerCase,但忽略大小寫,如果單詞在「引號」內部
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Globalization;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
private string ConvertToTitleCase(string val)
{
string returnString = string.Empty;
System.Globalization.CultureInfo info = System.Threading.Thread.CurrentThread.CurrentCulture;
TextInfo textInfo = info.TextInfo;
returnString = textInfo.ToTitleCase(val);
return returnString;
}
protected void Button1_Click(object sender, EventArgs e)
{
if (RadioButtonList1.SelectedValue == "a")
{
Label1.Text = System.Globalization.CultureInfo.CurrentCulture.TextInfo.ToTitleCase(TextBox1.Text);
Label1.Text = ConvertToTitleCase(TextBox1.Text);
TextBox1.Text.Equals(TextBox1.Text, StringComparison.CurrentCultureIgnoreCase);
}
else if (RadioButtonList1.SelectedValue == "b")
{
Label1.Text = "you have selected b";
}
else if (RadioButtonList1.SelectedValue == "c")
{
Label1.Text = TextBox1.Text.ToUpper();
}
else
Label1.Text = TextBox1.Text.ToLower();
}
我需要一個提示或代碼,將忽略首字母大寫,SentenceCase,大寫和小寫如果.. 我strring是裏面的「報價」
例:
字符串TextBox1的=您好,這是「ASP .net「。你是」B.Tech「並歡迎加入」HCT「。
輸出:
TitleCase:你好,這是「asp.net」。你在「B.Tech」並歡迎來到「HCT」。
判詞:您好,這是「asp.net」。您身處「B.Tech」,歡迎來到「HCT」。
大案:你好這是「asp.net」。你是「B.Tech」,歡迎來到「HCT」。
LowerCase:你好,這是「asp.net」。你在「B.Tech」,並歡迎來到「HCT」。
確定...和[你嘗試過什麼?](http://whathaveyoutried.com) – Blachshma 2013-03-27 23:34:01
我的問題是清楚的我認爲 – baluchi55 2013-03-27 23:49:35
我不是故意與你爭論,但問題不是那麼清楚。可以取悅你展示一些你寫的代碼,顯示你正在做什麼,哪些不起作用?另外,考慮到你是一位新用戶,並且擁有超過8K聲望的用戶(@Blachshma)提出建議,您應該聽取建議。 – 2013-03-28 00:07:18