开发者

.NET String Assignment Removes Characters [closed]

开发者 https://www.devze.com 2023-03-31 07:06 出处:网络
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references,or expertise, but this question will likely solicit debate, a
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 11 years ago.

Never seen anything like this before. I'm doing a very simple DataReader value assignment.

story.Byline = _r["Byline"].ToString();

But the values of _r["Byline"].ToString() and story.Byline are different after the assignment. Here's the output from the Immediate window:

story.Byline
"Associated Press - FIRST LASTAssociated Press - FIRST LAST"
_r["Byline"].ToString()
"Associated Press - FIRST LAST<br />Associate开发者_开发问答d Press - FIRST LAST"

Why is <br /> being removed?


Calling reader["x"].ToString() you actually calls x' type possibly overridden method ToString().

If you're sure that it's string, use reader.GetString(reader.GetOrdinal("x"))


Well, this is a bit embarrassing:

public string Byline
{
    get { return !_elements.ContainsKey("Byline") ? "" : (string)_elements["Byline"]; }
    set
    {
        string _buf = Functions.StripTags(value);
        _elements["Byline"] = _buf;
    }
}

Incorrect assumptions FTL. Can this question be deleted?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号