Skip to content

Commit

Permalink
fix: failed to parse Markdown attributes; you may need to quote the v…
Browse files Browse the repository at this point in the history
…alues.
  • Loading branch information
yangzhenghan committed Oct 25, 2023
1 parent bb20e44 commit bbf1eb0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions content/posts/Newtonsoft.NET 基本使用.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ TestJsonDeseClass des =

那么如果不想序列化/反序列化某个成员变量呢?

``` csharp {5}
``` csharp
using Newtonsoft.Json;

public class TestJsonDeseClass
Expand All @@ -62,7 +62,7 @@ public class TestJsonDeseClass

如果JSON字符串中的属性名字和定义的类中的成员名字不一样怎么办呢?怎样才能正确的给成员变量赋值呢?

```csharp {5}
```csharp
using Newtonsoft.Json;

public class TestJsonDeseClass
Expand All @@ -80,7 +80,7 @@ public class TestJsonDeseClass

当然这样也是可以的,不过需要我们给类添加构造方法,在构造方法中对成员赋值,不能再使用默认的构造方法,因为默认的构造方法不会对成员赋值,而外部也无法对成员赋值。在添加了构造方法后,Json.NET会自动调用类的构造方法。

``` csharp {9}
``` csharp
using Newtonsoft.Json;

public class TestJsonDeseClass
Expand All @@ -101,7 +101,7 @@ public class TestJsonDeseClass

如果把上面的构造方法改成下面这个样子

``` csharp {1}
``` csharp
public TestJsonDeseClass(Guid guid, string message)
{
MessageGuid = guid;
Expand All @@ -113,7 +113,7 @@ public TestJsonDeseClass(Guid guid, string message)

那么,最后一个问题,如果我的类有多个构造方法,我怎样告诉Json.NET应该用哪一个呢?

``` csharp {13}
``` csharp
using Newtonsoft.Json;

public class TestJsonDeseClass
Expand Down
2 changes: 1 addition & 1 deletion content/posts/使用 Named Pipe 进行进程间通讯.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ NamedPipeClientStream client = new NamedPipeClientStream(
client.Connect(); // 阻塞方式
```

``` csharp {6}
``` csharp
Task.Run(() =>
{
int bytesToRead;
Expand Down

0 comments on commit bbf1eb0

Please sign in to comment.