C# how to create a Guid value?

后端 未结 11 2137
旧时难觅i
旧时难觅i 2020-11-27 09:58

One field of our struct is Guid type. How to generate a valid value for it?

11条回答
  •  暖寄归人
    2020-11-27 10:27

    If you are using this in the Reflection C#, you can get the guid from the property attribute as follows

    var propertyAttributes= property.GetCustomAttributes();
    foreach(var attribute in propertyAttributes)
    {
      var myguid= Guid.Parse(attribute.Id.ToString());
    }
    
    
    

提交回复
热议问题