Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx). error?

Ask Question

I need to save those six fields in same column but not in same row and same cell. each field have default GUID.so i decided to put that default guid's in one list and fields in one list and call that object of that particular list where we want .

       ArrayList Alist = new ArrayList();
            Alist.Add("FD713788-B5AE-49FF-8B2C-F311B9CB0CC4");
            Alist.Add("64B512E7-46AE-4989-A049-A446118099C4");
            Alist.Add("376D45C8-659D-4ACE-B249-CFBF4F231915");
            Alist.Add("59A2449A-C5C6-45B5-AA00-F535D83AD48B");
            Alist.Add("03ADA903-D09A-4F53-8B67-7347A08EDAB1");
            Alist.Add("2F405521-06A0-427C-B9A3-56B8931CFC57");
        ArrayList objValue = new ArrayList();
            objValue.Add(viewmodel.TinNo);
            objValue.Add(viewmodel.CstNo);
            objValue.Add(viewmodel.PanNo);
            objValue.Add(viewmodel.CinNo);
            objValue.Add(viewmodel.ExciseRegNo);
            objValue.Add(viewmodel.ServiceTaxNo);
   var TaxInfoTaxFiledclassobj = new TaxInfoTaxFiled()
            TaxInfoTaxFieldID = TaxInfoTaxFieldObj,
            TaxFieldID = new Guid(Alist .ToString ()),
            FieldValue = objValue.ToString(),

All are working Fine but in TaxFieldID it show the count which has been calculated from list but while saving it show the below error

What shall I do?

For me, this error comes only when I debug the application in Visual Studio. If I launch the output EXE directly from the Debug folder, then this error never comes. It seems this issue has something to do with the VS Debugger as well. – RBT 2 days ago

You're trying to pass an ArrayList as a Guid. In this line:

TaxFieldID = Guid.Parse(Alist.ToString())

You need to select just one of the elements of the ArrayList to parse. Additionally, you could use a List<Guid> to eliminate the problem altogether.

List<Guid> guidList = new List<Guid>();
guidList.Add(new Guid("DDE4BA55-808E-479F-BE8B-72F69913442F"));
TaxFieldID = guidList[0]; // obviously, select the appropriate GUID
                steve  please tell i add my default guid as per you said and how to add my six fields same as like this as per you said
– Sruthi
                Jan 8, 2016 at 6:46
                I've just put the pertinent parts for the answer, the rest of the code will be the same as you had. This just deals with setting the Guid value.
– Steve
                Jan 8, 2016 at 6:47
                Do you mean a row for each Guid, or all Guids in one column in one row, perhaps separated by a comma or something?
– Steve
                Jan 8, 2016 at 6:49
                Yes  i need  to save  each guid  in row by row of same Column    in the below format                    [enter image description here][1]     [1]: i.stack.imgur.com/42dkd.png
– Sruthi
                Jan 8, 2016 at 6:53

I guess you're looking for something like this -

var listFiled = new List<TaxInfoTaxFiled>();
for(var item = 0; item < objValue.Count ; item++)
    listFiled.Add(new TaxInfoTaxFiled
        TaxInfoTaxFieldID = TaxInfoTaxFieldObj,
        TaxFieldID = new Guid(Alist[item]),
        FieldValue = objValue[item]
                i tried this also TaxFieldID = Guid.parse(Alist.Tostring()), this also showing same error
– Sruthi
                Jan 8, 2016 at 6:44
                Well one way is to use Guid.Parse() for each element in the array and then concatinate to a string before assigning.
– Amit Kumar Ghosh
                Jan 8, 2016 at 6:53
                if i concatinate means all values save in same column same cell. but i need to save in below format   i.stack.imgur.com/42dkd.png
– Sruthi
                Jan 8, 2016 at 6:57
        

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.