Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
285 views
in Technique[技术] by (71.8m points)

ASP.NET C# char Type displaying Special Character ?

I have an application that allows users to create applications. One of the fields in the application class is of data type char and named Offer. When I go to the create form to create an application. The Offer field is automatically filled with a special character ? (is the square character). Why is this happening? I cannot convert the char to string either to allow a 1 character input.

I have tried:

char chr = 'X';
Offer = chr,

char chr = 'X';
string str = chr.ToString();
Offer = str,

char chr = 'X';
Offer = chr.ToString()

Offer = Char.ToString('X')

Offer = Convert.ToChar(88) #ASCII for X

Offer = ((char)0x0058).ToString(); #0x0058 Binary Unicode for X

Am I doing something horribly wrong?

HTML for input box:

        <div class="form-group">
        @Html.LabelFor(model => model.Offer, htmlAttributes: new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            @Html.EditorFor(model => model.Offer, new { htmlAttributes = new { @class = "form-control" } })
            @Html.ValidationMessageFor(model => model.Offer, "", new { @class = "text-danger" })
        </div>
    </div>
question from:https://stackoverflow.com/questions/66056145/asp-net-c-sharp-char-type-displaying-special-character

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...