Skip to content

Commit c561df5

Browse files
committed
fixes MicrosoftDocs/visualstudio-docs#5907
1 parent ef1868f commit c561df5

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

docs/code-quality/codesnippet/CSharp/ca2240-implement-iserializable-correctly_1.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,27 @@ namespace Samples1
88
[Serializable]
99
public class Book : ISerializable
1010
{
11-
private readonly string _Text;
11+
private readonly string _Title;
1212

13-
public Book(string text)
13+
public Book(string title)
1414
{
15-
if (text == null)
16-
throw new ArgumentNullException("text");
15+
if (title == null)
16+
throw new ArgumentNullException("title");
1717

18-
_Text = text;
18+
_Title = title;
1919
}
2020

2121
protected Book(SerializationInfo info, StreamingContext context)
2222
{
2323
if (info == null)
2424
throw new ArgumentNullException("info");
2525

26-
_Text = info.GetString("Text");
26+
_Title = info.GetString("Title");
2727
}
2828

29-
public string Text
29+
public string Title
3030
{
31-
get { return _Text; }
31+
get { return _Title; }
3232
}
3333

3434
[SecurityPermission(SecurityAction.Demand, SerializationFormatter = true)]
@@ -37,7 +37,7 @@ public void GetObjectData(SerializationInfo info, StreamingContext context)
3737
if (info == null)
3838
throw new ArgumentNullException("info");
3939

40-
info.AddValue("Text", _Text);
40+
info.AddValue("Title", _Title);
4141
}
4242
}
4343

@@ -47,8 +47,8 @@ public class LibraryBook : Book
4747
{
4848
private readonly DateTime _CheckedOut;
4949

50-
public LibraryBook(string text, DateTime checkedOut)
51-
: base(text)
50+
public LibraryBook(string title, DateTime checkedOut)
51+
: base(title)
5252
{
5353
_CheckedOut = checkedOut;
5454
}

0 commit comments

Comments
 (0)