Guid应包含32位数字和4个破折号(xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)。错误? [英] Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx). error?
问题描述
我需要将这六个字段保存在同一列中,但不能保存在同一行和同一个单元格中。每个字段都有默认GUID。所以我决定将默认guid放在一个列表中,并将字段放在一个列表中,然后调用该特定列表中我们想要的对象。
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(),
};
所有工作正常但在TaxFieldID它显示从列表计算的计数,但保存时显示Guid应包含32位数字,包含4个破折号(xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)。错误?在TaxFieldID我该怎么做才能解决这个问题
All are working Fine but in TaxFieldID it show the count which has been calculated from list but while saving it shows Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx). error? in TaxFieldID what shall i do to resolve this probelm
推荐答案
您正在尝试将ArrayList
转换为Guid
。
You are trying to convert theArrayList
toGuid
.
TaxFieldID = new Guid(Alist .ToString ())
使用迭代器(对于/ while / foreach)迭代 ArrayList
项并转换每个项目。
在第一眼看,下面的行可能会抛出错误:
On the first look, below line may throw an error:
TaxFieldID = new Guid(Alist .ToString ()),
Guid构造函数不接受字符串数组,它接受单个字符串。
Guid constructor does not accept array of strings, it accepts single string.
Guid g = new Guid(Alist[0]);
请参阅:指导构造函数(系统) [ ^ ]
这篇关于Guid应包含32位数字和4个破折号(xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)。错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!