System.CodeDom.Tests.CSharpCodeGenerationTests.ClassWithInstanceFields C# (CSharp) Метод

ClassWithInstanceFields() приватный Метод

private ClassWithInstanceFields ( ) : void
Результат void
        public void ClassWithInstanceFields()
        {
            var cd = new CodeTypeDeclaration("SomeClass") { IsClass = true };
            cd.Members.Add(new CodeMemberField(typeof(int), "_privateNumber") { Attributes = MemberAttributes.Private });
            cd.Members.Add(new CodeMemberField(typeof(string), "_internalString") { Attributes = MemberAttributes.Assembly });
            cd.Members.Add(new CodeMemberField(typeof(DateTime), "_protectedDateTime") { Attributes = MemberAttributes.Family });
            cd.Members.Add(new CodeMemberField(typeof(TimeSpan), "PublicTimeSpan") { Attributes = MemberAttributes.Public });
            cd.Members.Add(new CodeMemberField(typeof(Guid), "_protectedInternalGuid") { Attributes = MemberAttributes.FamilyOrAssembly });

            AssertEqual(cd,
                @"public class SomeClass {
                      private int _privateNumber;
                      internal string _internalString;
                      protected System.DateTime _protectedDateTime;
                      public System.TimeSpan PublicTimeSpan;
                      protected internal System.Guid _protectedInternalGuid;
                  }");
        }