0

In an application, I have to use a valid identity string as a value of a property. I mean the string should be a valid identity name in C#.

For I want to use the string as a formula without change the source code of the component, I have to convert ANY formula, a string, to a valid identity string and convert it back when needed.Of course, when a formula is a valid identity name, the converting function should return it directly.

For example, the formula is Price*Quantity, and the converted value is Price__char_99__Quantity. For example, the formula is Price, and the converted value is Price.

Maybe there is such a function already there, but I took hours and failed to find it out. I guess in XML functions or string codes convertion, there must be some similar one.

Please give me a hand.

Thank you in advance.

Ying

Daniel Daranas
  • 22,454
  • 9
  • 63
  • 116
Ying
  • 61
  • 2
  • 1
    I think you might get some answers if the question was more readable - I am having a hard time understanding what the problem is. Code speaks a thousand words. – User2400 Apr 23 '10 at 07:43
  • 1
    See http://stackoverflow.com/questions/157646/best-way-to-encode-text-data-for-xml. Deals with XML text, not sure not it helps with XML identity strings though. – anonymous Apr 23 '10 at 07:44
  • @fneep, I think @Ying's asking for a way to create valid XML strings that can be used as XML tags. – anonymous Apr 23 '10 at 07:47

1 Answers1

0

I would be easier if you create a new class, Formula, rather than attempt to use a string for your forumla property. The Formula class would hold the original text of the formula as a property, so you would not need to convert. You can then create a List to hold any number of Forumula objects. This would be much easier to do than your current solution.

Polyfun
  • 9,479
  • 4
  • 31
  • 39