Home > Net >  Suddenly there was a very odd ba needs, how to set the variable name the duty.
Suddenly there was a very odd ba needs, how to set the variable name the duty.

Time:12-25

My idea is like this, precisely, should be in the inside of the object key name, say it is

String strHtml=fromStr;
For traversing an object
{
StrHtml +=strHtml. Replace (variable name, the value of the variable);
}

Look, is there a way to achieve

CodePudding user response:

Hash table?

CodePudding user response:

Put the dictionary, the object's key, object value

CodePudding user response:

Json can satisfy your requirement

CodePudding user response:

A dictionary or a json can be implemented

CodePudding user response:

refer to the original poster goodgame365 response:
my idea is like this, precisely, should be made inside the object key name, said a

String strHtml=fromStr;
For traversing an object
{
StrHtml +=strHtml. Replace (variable name, the value of the variable);
}

Look, is there any way to achieve


Don't have such template language, ${variable name}, then there is the value of the corresponding

CodePudding user response:

Use a dictionary to solve, this simple

CodePudding user response:

Look at your variable name, do you want to modify the HTML file content? Try this: HTML agility pack

CodePudding user response:

????? Object. The variable name is not value? Ah?

CodePudding user response:

Baidu "c # text template engine"

CodePudding user response:

With baidu once, out of the first article

https://blog.csdn.net/yelin042/article/details/93380796

CodePudding user response:

Dictionary OpenWith=new Dictionary (a);

//traverse a dictionary
The foreach (KeyValuePair KVP in openWith)
{
Console. WriteLine (" Key={0}, {1} "Value=https://bbs.csdn.net/topics/, KVP. Key, KVP, Value);
}

CodePudding user response:

Variable, type or member name as string constants, I generally use nameof, I don't know if this is what you want,
https://docs.microsoft.com/zh-cn/dotnet/csharp/language-reference/operators/nameof
  •  Tags:  
  • C#
  • Related