我可以在vb.net中将关键字用作propertyname吗?
我必须将类序列化/反序列化为JSON字符串/并返回。JSON字符串必须包含“error”字符串(比如:{error:“奇怪的occoured”,id:23,result:“xxxxx”}),它指定了occoured错误 如何实现以下类:我可以在vb.net中将关键字用作propertyname吗?,vb.net,asp.net-mvc-2,Vb.net,Asp.net Mvc 2,我必须将类序列化/反序列化为JSON字符串/并返回。JSON字符串必须包含“error”字符串(比如:{error:“奇怪的occoured”,id:23,result:“xxxxx”}),它指定了occoured错误 如何实现以下类: Public Class JsonResponse Public result As JsonResult Public error As String Public id As Integer End Class 如果我这样做,“错
Public Class JsonResponse
Public result As JsonResult
Public error As String
Public id As Integer
End Class
如果我这样做,“错误”一词是无效的
谢谢用方括号括起来
Public Class JsonResponse
Public result As JsonResult
Public [error] As String
Public id As Integer
End Class
HTH在名称周围使用[]:
Public Class JsonResponse
Public result As JsonResult
Public [error] As String
Public id As Integer
End Class
[]到底在做什么?它们允许您对方法、类或成员名称使用保留字。更多信息:它们不是用于一般用途,但在与您所处的环境完全相同的情况下,没有太多的替代方案。