开发者

can i use a keyword as a propertyname in vb .net?

开发者 https://www.devze.com 2023-03-02 17:33 出处:网络
I have to serialize/deserialize a class into a JSON string/and return. The JSON Strinig must contain the 开发者_开发知识库\"error\" string (like: {error:\"something strange occoured\", id:23, result:\

I have to serialize/deserialize a class into a JSON string/and return. The JSON Strinig must contain the 开发者_开发知识库"error" string (like: {error:"something strange occoured", id:23, result:"xxxxx"}), which specifies the occoured error.

How can i implement a class like:

Public Class JsonResponse
    Public result As JsonResult
    Public error As String
    Public id As Integer
 End Class

If i do this, the word 'error' is invalid.

Thanks


Surround it with square brackets

Public Class JsonResponse
    Public result As JsonResult
    Public [error] As String
    Public id As Integer
 End Class

HTH


Use [] around the name:

Public Class JsonResponse
   Public result As JsonResult
   Public [error] As String
   Public id As Integer
End Class
0

精彩评论

暂无评论...
验证码 换一张
取 消