Click here to Skip to main content
12,755,986 members (37,495 online)
Click here to Skip to main content
Articles » Languages » C# » General » Downloads

Tagged as

Stats

68.5K views
1.7K downloads
150 bookmarked
Posted 12 Oct 2011

How does it work in C#? - Part 2

, 4 Feb 2013 CPOL
How does throw, rethrow and where, select clause of Enumerable class work in C# programming language.
Demo
TestHarnessPart2.exe
HowDoesItWork
HowDoesItWork.sln.vsdoc
HowDoesItWork.suo
TestHarness
bin
Debug
TestHarness.exe
TestHarness.pdb
TestHarness.vshost.exe
TestHarness.vshost.exe.manifest
obj
x86
Debug
DesignTimeResolveAssemblyReferencesInput.cache
TempPE
TestHarness.exe
TestHarness.pdb
Properties
TestHarness.vsdoc
TestHarnessPart2
bin
Debug
TestHarnessPart2.exe
TestHarnessPart2.pdb
TestHarnessPart2.vshost.exe
Release
obj
x86
Debug
DesignTimeResolveAssemblyReferencesInput.cache
TempPE
TestHarnessPart2.exe
TestHarnessPart2.pdb
Properties
TestHarnessPart2.vsdoc
namespace TestHarness
{
    using System.Collections.Generic;
    using System.Linq;
    using System.Reflection;

    public class AutoImplementatedProperties
    {
        public IEnumerable<string> ExploreMembers(Person personObject)
        {
            return personObject.GetType().GetMembers().ToList<MemberInfo>().Select(memberInfo => memberInfo.Name);
        }

        public IEnumerable<string> ExplorePrivateFields(Person personObject)
        {
            return personObject.GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Instance).Select(fieldInfo => string.Format("{0,40}-->{1,20}", fieldInfo.Name, fieldInfo.GetValue(personObject).ToString()));
        }

        public Person CreateATestObject()
        {
            Person personObject = new Person()
            {
                Name = "M",
                Profession = "Coding"
            };
            return personObject;
        }
    }

    public class Person
    {
        public string Name { get; set; }
        public string Profession { get; set; }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author


You may also be interested in...

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170217.1 | Last Updated 4 Feb 2013
Article Copyright 2011 by Mohammad A Rahman
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid