문제

Is it possible to use Guids as the identifier in resource files?

In my program the user will be able to chose between some possible types when he creates an item. Which item was chosen is saved via a Guid.

But the hyphens in the Guids seem to be a problem for the resource files. Is there a better solution that to use Replace in order to remove every hyphen from the Guid before looking up the typename in the current language?

도움이 되었습니까?

해결책

How are you turning the Guids into strings?

You can use Guid.ToString("N") to produce a string guid without any hyphens.

You may have to put a non-digit at the start too - if you do, it's probably easiest to do it with String.Format():

string guidStr = string.Format("X{0:N}", Guid.NewGuid()); // Prefix with "X"
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top