locked
How can i get the string representation of the int value from OptionSetValueCollection ? RRS feed

  • Question

  • User1253338400 posted

    Hi ,

    if i ave a string lets say :

    100000000;100000001;100000002

    I do a split on this and get values 100000000, 100000001, 100000002. How can i get the string value from a OptionSetValueCollection in crm ?

    So , 100000000 might be swimming 

    thanks

    Friday, November 8, 2019 4:26 AM

Answers

  • User-719153870 posted

    Hi robby32,

    How can i get the string value from a OptionSetValueCollection in crm ?

    What do you have in this OptionSetValueCollection? Three int numbers you mentioned above?

    And this might out of this forum's serve range since you said it's in crm.

    However, in c# program we can get string value from a OptionSetValueCollection very easy, you can refer to How to Get Formatted values in c# code from MultiselectOptionSet and below demo:

    OptionSetValueCollection a = new OptionSetValueCollection();
                a.Add(new OptionSetValue(100000000));
                a.Add(new OptionSetValue(100000001));
                a.Add(new OptionSetValue(100000002));
                foreach (var i in a)
                {
                    var t = a.Where(x => x.Value == i.Value).FirstOrDefault().Value.ToString();
                    Console.Write(t + Environment.NewLine);
                }

    Best Regard,

    Yang Shen

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, November 8, 2019 6:11 AM