<?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel><title>Nannette Thacker ShiningStar.net</title><link>https://weblogs.asp.net:443/nannettethacker/</link><description>&lt;a href="http://weblogs.asp.net/nannettethacker/pages/senior-web-application-developer-consultant.aspx"&gt;ASP.net Web Application Development&lt;/a&gt;</description><item><title>'X' is ambiguous in the namespace</title><link>https://weblogs.asp.net:443/nannettethacker/x-is-ambiguous-in-the-namespace</link><description>&lt;p&gt;I upgraded my projects with the latest version of a third party control (happened to be Telerik, but I've seen the problem occur other times as well) and got the ominous error on the BUILD:&lt;/p&gt;&lt;p&gt;&amp;nbsp;'Filename' is ambiguous in the namespace.&lt;/p&gt;&lt;p&gt;The path led to the temporary folders directory. I've read a post where someone deleted all the files in the directory. But that was after I already fixed it.&lt;/p&gt;&lt;p&gt;&amp;nbsp;The fix is simple, use REBUILD instead of BUILD.&lt;/p&gt;&lt;p&gt;&amp;nbsp;BTW, I'm using Visual Studio 2010 and Framework 4.0.&lt;/p&gt;&lt;p&gt; [SIGNATURE]&lt;/p&gt;</description><pubDate>Wed, 30 Jan 2013 19:48:00 GMT</pubDate><guid isPermaLink="true">https://weblogs.asp.net:443/nannettethacker/x-is-ambiguous-in-the-namespace</guid><category>ASP.NET</category><category>Visual Studio</category></item><item><title>Google Chrome Loses ASP.NET Sessions - Need FavIcon</title><link>https://weblogs.asp.net:443/nannettethacker/google-chrome-loses-asp-net-sessions-need-favicon</link><description>&lt;p&gt;I had programmed a brilliant web page in ASP.NET 4.0 and lo and behold, this one page lost its sessions in Google Chrome. I could run it locally in debug and could not reproduce the issues in Chrome. Didn't happen in IE or Firefox, only Chrome on the published server.&lt;/p&gt;&lt;p&gt;I finally found in a forum where someone mentioned that Google Chrome looks for favicons and if it doesn't find one it will throw a 302 redirect and kill the session.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;a href="http://stackoverflow.com/questions/8247842/session-data-lost-in-chrome-only"&gt;http://stackoverflow.com/questions/8247842/session-data-lost-in-chrome-only&lt;/a&gt;&lt;/p&gt;&lt;p&gt;"The issue could be your server is looking for favicons, if it is not found the server throws out a 302 redirect, which kills the session variables."&lt;/p&gt;&lt;p&gt;&amp;nbsp;So I went to Google and searched for a favicon generator, found one here at &lt;a href="http://www.favicon.cc/"&gt;http://www.favicon.cc/&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Uploaded a file which they turned into a favicon.&lt;/p&gt;&lt;p&gt;Then in my MasterPage within the HTML head tag and below the title tag I added the favicon code:&lt;/p&gt;&lt;p&gt;&lt;font color="#800000" size="2" face="Consolas"&gt;&lt;font color="#800000" size="2" face="Consolas"&gt;&lt;font color="#800000" size="2" face="Consolas"&gt;&amp;lt;link&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2" face="Consolas"&gt;&lt;font size="2" face="Consolas"&gt; &lt;/font&gt;&lt;/font&gt;&lt;font color="#ff0000" size="2" face="Consolas"&gt;&lt;font color="#ff0000" size="2" face="Consolas"&gt;&lt;font color="#ff0000" size="2" face="Consolas"&gt;rel&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2" face="Consolas"&gt;&lt;font color="#0000ff" size="2" face="Consolas"&gt;&lt;font color="#0000ff" size="2" face="Consolas"&gt;="shortcut icon"&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2" face="Consolas"&gt;&lt;font size="2" face="Consolas"&gt; &lt;/font&gt;&lt;/font&gt;&lt;font color="#ff0000" size="2" face="Consolas"&gt;&lt;font color="#ff0000" size="2" face="Consolas"&gt;&lt;font color="#ff0000" size="2" face="Consolas"&gt;type&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2" face="Consolas"&gt;&lt;font color="#0000ff" size="2" face="Consolas"&gt;&lt;font color="#0000ff" size="2" face="Consolas"&gt;="image/x-icon"&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2" face="Consolas"&gt;&lt;font size="2" face="Consolas"&gt; &lt;/font&gt;&lt;/font&gt;&lt;font color="#ff0000" size="2" face="Consolas"&gt;&lt;font color="#ff0000" size="2" face="Consolas"&gt;&lt;font color="#ff0000" size="2" face="Consolas"&gt;href&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2" face="Consolas"&gt;&lt;font color="#0000ff" size="2" face="Consolas"&gt;&lt;font color="#0000ff" size="2" face="Consolas"&gt;="~/Site/Images/favicon.ico"&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2" face="Consolas"&gt;&lt;font size="2" face="Consolas"&gt; &lt;/font&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2" face="Consolas"&gt;&lt;font color="#0000ff" size="2" face="Consolas"&gt;&lt;font color="#0000ff" size="2" face="Consolas"&gt;/&amp;gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;font color="#0000ff" size="2" face="Consolas"&gt;&lt;font color="#0000ff" size="2" face="Consolas"&gt;&lt;font color="#0000ff" size="2" face="Consolas"&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;p&gt;Published the code and checked it out and it fixed it!&lt;/p&gt;&lt;p&gt;Here's hoping this helps you with your Chrome Nightmares!&lt;/p&gt;&lt;p&gt;&amp;nbsp;[SIGNATURE]&lt;/p&gt;</description><pubDate>Fri, 09 Nov 2012 20:51:00 GMT</pubDate><guid isPermaLink="true">https://weblogs.asp.net:443/nannettethacker/google-chrome-loses-asp-net-sessions-need-favicon</guid><category>ASP.NET</category></item><item><title>4 Year Anniversary Posting on Weblogs.Asp.Net!</title><link>https://weblogs.asp.net:443/nannettethacker/4-year-anniversary-posting-on-weblogs-asp-net</link><description>&lt;p&gt;On January 24th, 2012 I celebrate my 4th year of writing on this blog. I have written over 140 posts and have received over 700 comments.&lt;/p&gt;&lt;p&gt;Thank you readers for your support!&lt;/p&gt;&lt;p&gt;[SIGNATURE]&lt;/p&gt;</description><pubDate>Tue, 24 Jan 2012 14:22:00 GMT</pubDate><guid isPermaLink="true">https://weblogs.asp.net:443/nannettethacker/4-year-anniversary-posting-on-weblogs-asp-net</guid><category>MVC3 Razor</category></item><item><title>ChangePassword Method for Entity Framework MVC3 Razor Custom Member Provider C# Using LINQ</title><link>https://weblogs.asp.net:443/nannettethacker/changepassword-method-for-entity-framework-mvc3-razor-custom-member-provider-c-using-linq</link><description>From my &lt;a href="/nannettethacker/archive/2012/01/11/mvc3-razor-entity-framework-amp-linq-custom-membership-provider-with-custom-role-provider.aspx" target="_blank" mce_href="/nannettethacker/archive/2012/01/11/mvc3-razor-entity-framework-amp-linq-custom-membership-provider-with-custom-role-provider.aspx"&gt;C# MVC3 Razor Custom Membership Provider&lt;/a&gt; article and source code, here is the code for the ChangePassword method. I welcome any suggestions for improvement.&lt;br&gt;&lt;font size="1"&gt;
&lt;pre&gt;public override bool ChangePassword(string username, 
    string oldPassword, string newPassword)
{
    try
    {
        byte[] hashedNewPassword = HashPassword(newPassword.Trim());
        byte[] hashedOldPassword = HashPassword(oldPassword.Trim());
        using (var context = new SSSEntities())
        {
            UserProfile u = context.UserProfiles
            .SingleOrDefault(up =&amp;gt; up.UserName == username &amp;amp;&amp;amp; 
                up.UserPassword == hashedOldPassword);
            if (u != null)
            {
                u.UserPassword = hashedNewPassword;
                context.SaveChanges();
                return true;
            }
            else
                return false;
        }
    }
    catch (InvalidOperationException ex)
    {
        throw ex;
    }
    catch (ArgumentException)
    {
        throw;
    }
}&lt;/pre&gt;&lt;/font&gt;&lt;br&gt;[SIGNATURE]</description><pubDate>Wed, 18 Jan 2012 21:37:00 GMT</pubDate><guid isPermaLink="true">https://weblogs.asp.net:443/nannettethacker/changepassword-method-for-entity-framework-mvc3-razor-custom-member-provider-c-using-linq</guid><category>ASP.NET</category><category>C#</category><category>Custom MembershipProvider</category><category>Entity Framework</category><category>General Software Development</category><category>Linq - Entities</category><category>MVC3 Razor</category></item><item><title>GetUser Methods for Entity Framework MVC3 Razor Custom Member Provider C# Using LINQ</title><link>https://weblogs.asp.net:443/nannettethacker/getuser-and-getmembershipuser-methods-for-entity-framework-mvc3-razor-custom-member-provider-c-using-linq</link><description>From my &lt;a href="/nannettethacker/archive/2012/01/11/mvc3-razor-entity-framework-amp-linq-custom-membership-provider-with-custom-role-provider.aspx" target="_blank" mce_href="/nannettethacker/archive/2012/01/11/mvc3-razor-entity-framework-amp-linq-custom-membership-provider-with-custom-role-provider.aspx"&gt;C# MVC3 Razor Custom Membership Provider&lt;/a&gt; article and source code, here is the code for the GetUser methods. I welcome any suggestions for improvement.&lt;br&gt;
&lt;font size="1"&gt;
&lt;pre&gt;public override MembershipUser GetUser(object providerUserKey, bool userIsOnline)
{
    using (var context = new SSSEntities())
    {
        UserProfile u = context.UserProfiles
                    .SingleOrDefault(up =&amp;gt; up.UserId == Convert.ToInt32(providerUserKey));
        MembershipUser membershipUser = &lt;a href="/nannettethacker/archive/2012/01/12/getmembershipuser-helper-method-for-entity-framework-mvc3-razor-custom-member-provider-c-using-linq.aspx" mce_href="/nannettethacker/archive/2012/01/12/getmembershipuser-helper-method-for-entity-framework-mvc3-razor-custom-member-provider-c-using-linq.aspx"&gt;GetMembershipUser&lt;/a&gt;(u);
        return membershipUser;
    }
}
public override MembershipUser GetUser(string username, bool userIsOnline)
{
    using (var context = new SSSEntities())
    {
        UserProfile u = context.UserProfiles
            .SingleOrDefault(up =&amp;gt; up.UserName == username);
        MembershipUser membershipUser = &lt;a href="/nannettethacker/archive/2012/01/12/getmembershipuser-helper-method-for-entity-framework-mvc3-razor-custom-member-provider-c-using-linq.aspx" mce_href="/nannettethacker/archive/2012/01/12/getmembershipuser-helper-method-for-entity-framework-mvc3-razor-custom-member-provider-c-using-linq.aspx"&gt;GetMembershipUser&lt;/a&gt;(u);
        return membershipUser;
    }
}
// custom method to return a UserProfile
public UserProfile GetUser(string username)
{
    using (var context = new SSSEntities())
    {
        UserProfile u = context.UserProfiles
            .SingleOrDefault(up =&amp;gt; up.UserName == username);
        return u;
    }
}
// custom method to return a UserProfile
public UserProfile GetUser(object providerUserKey)
{
    using (var context = new SSSEntities())
    {
        UserProfile u = context.UserProfiles
                    .SingleOrDefault(up =&amp;gt; up.UserId == Convert.ToInt32(providerUserKey));
        return u;
    }
}

&lt;/pre&gt;&lt;/font&gt;
&lt;br&gt;
[SIGNATURE]</description><pubDate>Tue, 17 Jan 2012 21:32:00 GMT</pubDate><guid isPermaLink="true">https://weblogs.asp.net:443/nannettethacker/getuser-and-getmembershipuser-methods-for-entity-framework-mvc3-razor-custom-member-provider-c-using-linq</guid><category>ASP.NET</category><category>C#</category><category>Custom MembershipProvider</category><category>Entity Framework</category><category>General Software Development</category><category>Linq - Entities</category><category>MVC3 Razor</category></item><item><title>Custom Error Pages and 404 Page Not Found Error Web.Config Setup</title><link>https://weblogs.asp.net:443/nannettethacker/custom-error-pages-and-404-page-not-found-error-web-config-setup</link><description>&lt;p&gt;When receiving 404 page not found errors on your web site, and you wish to direct users back to your home page, you need to setup two things in your web.config to handle all instances.&lt;/p&gt;

&lt;p&gt;If you use IIS7 and go to the Error Pages section and setup the 404 error to "Execute a URL on this site" and have it go to : /default.aspx and select OK to save the changes, it will update your system.webServer section of your web.config file and add these lines:&lt;/p&gt;

&lt;pre&gt;&amp;lt;httpErrors&amp;gt;
    &amp;lt;remove statusCode="404" subStatusCode="-1" /&amp;gt;
    &amp;lt;error statusCode="404" prefixLanguageFilePath="" &lt;br&gt;             path="/default.aspx" &lt;br&gt;             responseMode="ExecuteURL" /&amp;gt;
&amp;lt;/httpErrors&amp;gt;
&lt;/pre&gt;
&lt;p&gt;
This will redirect any pages such as &lt;a href="http://www.shiningstar.net/test" mce_href="http://www.shiningstar.net/test"&gt;http://www.shiningstar.net/test&lt;/a&gt; with no file extensions. But if the URL sends the user to a page with a known file extension, they will still be taken to the 404 error page.&lt;/p&gt;
&lt;p&gt;So if you want to redirect a page such as &lt;a href="http://www.shiningstar.net/test.aspx" mce_href="http://www.shiningstar.net/test.aspx"&gt;http://www.shiningstar.net/test.aspx&lt;/a&gt;&amp;nbsp;you will also need to add custom error handling to your system.web section of your web configuration file:&lt;/p&gt;


&lt;pre&gt;&amp;lt;customErrors mode="RemoteOnly" &lt;br&gt;     defaultRedirect="~/ErrorPages/Error.aspx"&amp;gt;
    &amp;lt;error statusCode="404" redirect="~/default.aspx"/&amp;gt;
&amp;lt;/customErrors&amp;gt;
&lt;/pre&gt;&lt;p&gt;
&lt;br&gt;
The 3 options for the mode are: Off, On, and RemoteOnly. To test your error handling locally, change the mode to "On." Once you've tested it, change it to "RemoteOnly" which will&amp;nbsp;still allow you to receive descriptive errors when developing locally.&lt;/p&gt;&lt;p&gt;[SIGNATURE]&lt;/p&gt;</description><pubDate>Sun, 15 Jan 2012 21:20:00 GMT</pubDate><guid isPermaLink="true">https://weblogs.asp.net:443/nannettethacker/custom-error-pages-and-404-page-not-found-error-web-config-setup</guid><category>ASP.NET</category><category>General Software Development</category><category>IIS7</category></item><item><title>CreateUser Method for Entity Framework MVC3 Razor Custom Member Provider C# Using LINQ</title><link>https://weblogs.asp.net:443/nannettethacker/createuser-method-for-entity-framework-mvc3-razor-custom-member-provider-c-using-linq</link><description>From my &lt;a href="/nannettethacker/archive/2012/01/11/mvc3-razor-entity-framework-amp-linq-custom-membership-provider-with-custom-role-provider.aspx" target="_blank" mce_href="/nannettethacker/archive/2012/01/11/mvc3-razor-entity-framework-amp-linq-custom-membership-provider-with-custom-role-provider.aspx"&gt;C# MVC3 Razor Custom Membership Provider&lt;/a&gt; article and source code, here is the code for the CreateUser method. I welcome any suggestions for improvement.&lt;br&gt;
&lt;font size="1"&gt;
&lt;pre&gt;public override MembershipUser CreateUser(string username, string password,
    string email, string passwordQuestion, string passwordAnswer,
    bool isApproved, object providerUserKey, out MembershipCreateStatus status)
{
    // only first 3 fields are passed in from the AccountModels.cs
    try
    {
        status = &lt;a href="/nannettethacker/archive/2012/01/13/usernameexists-amp-duplicateemail-helper-methods-for-entity-framework-mvc3-razor-custom-member-provider-c-using-linq.aspx" mce_href="/nannettethacker/archive/2012/01/13/usernameexists-amp-duplicateemail-helper-methods-for-entity-framework-mvc3-razor-custom-member-provider-c-using-linq.aspx"&gt;UsernameExists&lt;/a&gt;(username);
        if (status == MembershipCreateStatus.DuplicateUserName)
        {
            return null;
        }
        status = &lt;a href="/nannettethacker/archive/2012/01/13/usernameexists-amp-duplicateemail-helper-methods-for-entity-framework-mvc3-razor-custom-member-provider-c-using-linq.aspx" mce_href="/nannettethacker/archive/2012/01/13/usernameexists-amp-duplicateemail-helper-methods-for-entity-framework-mvc3-razor-custom-member-provider-c-using-linq.aspx"&gt;DuplicateEmail&lt;/a&gt;(email);
        if (status == MembershipCreateStatus.DuplicateEmail)
        {
            return null;
        }

        byte[] hashedPassword = &lt;a href="/nannettethacker/archive/2012/01/12/hashpassword-method-for-entity-framework-mvc3-razor-custom-member-provider-c-using-linq.aspx" mce_href="/nannettethacker/archive/2012/01/12/hashpassword-method-for-entity-framework-mvc3-razor-custom-member-provider-c-using-linq.aspx"&gt;HashPassword&lt;/a&gt;(password.Trim());
        GetValues gv = new GetValues();
        string ipAddress = gv.getIPAddress();
        int userStatus = 
            Convert.ToInt32(SSS.GlobalListValues.Enums.UserStatusCode.Active);

        using (var context = new SSSEntities())
        {
            UserProfile newUser = new UserProfile()
            {
                Email = email,
                UserPassword = hashedPassword,
                UserName = username,
                DateCreated = DateTime.Now,
                DateUpdated = DateTime.Now,
                DatePasswordLastChanged = DateTime.Now,
                DateLastLogin = DateTime.Now,
                UserStatusCode = userStatus,
                IpAddress = ipAddress,
            };


            // insert the User Role
            int userRole = 
                Convert.ToInt32(SSS.GlobalListValues.Enums.UserRoleCode.User_Public);
            // look up the desired user role : 
            // uses a UserRole join table with a many to many relation
            // between the UserProfile table and the ListValue table
            ListValue ur = context.ListValues
                .SingleOrDefault(lv =&amp;gt; lv.ListValueId == userRole);
            newUser.UserProfileUserRoles.Add(ur);

            context.UserProfiles.AddObject(newUser);
            context.SaveChanges();

            // NKT: after creation, go back and retrieve the auto-generated identity key and 
            // update the userId's for the created and updated userId
            int userId = newUser.UserId;
            newUser.CreatedUserId = userId;
            newUser.UpdatedUserId = userId;

            context.SaveChanges();
            status = MembershipCreateStatus.Success;
            return &lt;a href="/nannettethacker/archive/2012/01/12/getmembershipuser-helper-method-for-entity-framework-mvc3-razor-custom-member-provider-c-using-linq.aspx" mce_href="/nannettethacker/archive/2012/01/12/getmembershipuser-helper-method-for-entity-framework-mvc3-razor-custom-member-provider-c-using-linq.aspx"&gt;GetMembershipUser&lt;/a&gt;(newUser);
        }
    }
    catch (ArgumentException)
    {
        status = MembershipCreateStatus.ProviderError;
        return null;
    }

}&lt;/pre&gt;&lt;/font&gt;
&lt;br&gt;
[SIGNATURE]</description><pubDate>Sun, 15 Jan 2012 21:00:00 GMT</pubDate><guid isPermaLink="true">https://weblogs.asp.net:443/nannettethacker/createuser-method-for-entity-framework-mvc3-razor-custom-member-provider-c-using-linq</guid><category>ASP.NET</category><category>C#</category><category>Custom MembershipProvider</category><category>Entity Framework</category><category>General Software Development</category><category>Linq - Entities</category><category>MVC3 Razor</category></item><item><title>DeleteUser Method for Entity Framework MVC3 Razor Custom Member Provider C# Using LINQ</title><link>https://weblogs.asp.net:443/nannettethacker/deleteuser-method-for-entityframework-mvc3-razor-custom-member-provider-c-using-linq</link><description>From my &lt;a href="/nannettethacker/archive/2012/01/11/mvc3-razor-entity-framework-amp-linq-custom-membership-provider-with-custom-role-provider.aspx" target="_blank" mce_href="/nannettethacker/archive/2012/01/11/mvc3-razor-entity-framework-amp-linq-custom-membership-provider-with-custom-role-provider.aspx"&gt;C# MVC3 Razor Custom Membership Provider&lt;/a&gt; article and source code, here is the code for the DeleteUser method. I welcome any suggestions for improvement.&lt;br&gt;
&lt;font size="1"&gt;
&lt;pre&gt;public override bool DeleteUser(string username, bool deleteAllRelatedData)
{
    // deleteAllRelatedData not implemented
    try
    {
        using (var context = new SSSEntities())
        {

            UserProfile u = context.UserProfiles
                .SingleOrDefault(up =&amp;gt; up.UserName == username);

            context.UserProfiles.DeleteObject(u);
            context.SaveChanges();
            return true;
        }
    }
    catch
    {
        return false;
    }

&lt;/pre&gt;&lt;/font&gt;
&lt;br&gt;
[SIGNATURE]</description><pubDate>Fri, 13 Jan 2012 19:35:00 GMT</pubDate><guid isPermaLink="true">https://weblogs.asp.net:443/nannettethacker/deleteuser-method-for-entityframework-mvc3-razor-custom-member-provider-c-using-linq</guid><category>ASP.NET</category><category>C#</category><category>Custom MembershipProvider</category><category>Entity Framework</category><category>General Software Development</category><category>Linq - Entities</category><category>MVC3 Razor</category></item><item><title>UsernameExists &amp; DuplicateEmail Helper Methods for Entity Framework MVC3 Razor Custom Member Provider C# Using LINQ</title><link>https://weblogs.asp.net:443/nannettethacker/usernameexists-amp-duplicateemail-helper-methods-for-entity-framework-mvc3-razor-custom-member-provider-c-using-linq</link><description>From my &lt;a href="/nannettethacker/archive/2012/01/11/mvc3-razor-entity-framework-amp-linq-custom-membership-provider-with-custom-role-provider.aspx" target="_blank" mce_href="/nannettethacker/archive/2012/01/11/mvc3-razor-entity-framework-amp-linq-custom-membership-provider-with-custom-role-provider.aspx"&gt;C# MVC3 Razor Custom Membership Provider&lt;/a&gt; article and source code, here is the code for the UsernameExists &amp;amp; DuplicateEmail Helper methods. I welcome any suggestions for improvement.&lt;br&gt;&lt;font size="1"&gt;
&lt;pre&gt;// helper method
public MembershipCreateStatus UsernameExists(string username)
{
    using (var context = new SSSEntities())
    {
        if (context.UserProfiles.Any(
                    u =&amp;gt; u.UserName == username))
        {
            return MembershipCreateStatus.DuplicateUserName;
        }
        return MembershipCreateStatus.Success;
    }
}

// helper method
public MembershipCreateStatus DuplicateEmail(string email)
{
    using (var context = new SSSEntities())
    {
        if (context.UserProfiles.Any(
                    u =&amp;gt; u.Email == email))
        {
            return MembershipCreateStatus.DuplicateEmail;
        }
        return MembershipCreateStatus.Success;
    }
}
&lt;/pre&gt;&lt;/font&gt;&lt;br&gt;&lt;font size="3"&gt;[SIGNATURE]&lt;/font&gt;</description><pubDate>Fri, 13 Jan 2012 14:01:00 GMT</pubDate><guid isPermaLink="true">https://weblogs.asp.net:443/nannettethacker/usernameexists-amp-duplicateemail-helper-methods-for-entity-framework-mvc3-razor-custom-member-provider-c-using-linq</guid><category>ASP.NET</category><category>C#</category><category>Custom MembershipProvider</category><category>Entity Framework</category><category>General Software Development</category><category>Linq - Entities</category></item><item><title>GetMembershipUser Helper Method for Entity Framework MVC3 Razor Custom Member Provider C# Using LINQ</title><link>https://weblogs.asp.net:443/nannettethacker/getmembershipuser-helper-method-for-entity-framework-mvc3-razor-custom-member-provider-c-using-linq</link><description>From my &lt;a href="/nannettethacker/archive/2012/01/11/mvc3-razor-entity-framework-amp-linq-custom-membership-provider-with-custom-role-provider.aspx" target="_blank" mce_href="/nannettethacker/archive/2012/01/11/mvc3-razor-entity-framework-amp-linq-custom-membership-provider-with-custom-role-provider.aspx"&gt;C# MVC3 Razor Custom Membership Provider&lt;/a&gt; article and source code, here is the code for the GetMembershipUser Helper method. I welcome any suggestions for improvement. Since we are working with a UserProfile Entity and the Membership Provider overridable methods require we return a MembershipUser type, below we create our MembershipUser type using values from our UserProfile type so we can return the required type in our methods.&lt;br&gt;&lt;font size="1"&gt;
&lt;pre&gt;// helper method
public MembershipUser GetMembershipUser(UserProfile u)
{
    // copy pertinent UserProfile data to the MembershipUser &lt;br&gt;   // data to be returned as a MembershipUser type
    object userIDObj = u.UserId;

    MembershipUser membershipUser = new MembershipUser(
            this.Name,
            u.UserName,
            userIDObj,
            u.Email,
            string.Empty,
            string.Empty,
            true,
            false,
            (DateTime)u.DateCreated,
            (DateTime)u.DateLastLogin,
            (DateTime)u.DateUpdated,
            (DateTime)u.DateLastLogin,
            (DateTime)u.DateLastLogin);

    return membershipUser;
}

&lt;/pre&gt;&lt;/font&gt;&lt;br&gt;[SIGNATURE]</description><pubDate>Thu, 12 Jan 2012 20:56:00 GMT</pubDate><guid isPermaLink="true">https://weblogs.asp.net:443/nannettethacker/getmembershipuser-helper-method-for-entity-framework-mvc3-razor-custom-member-provider-c-using-linq</guid><category>ASP.NET</category><category>C#</category><category>Custom MembershipProvider</category><category>Entity Framework</category><category>General Software Development</category><category>Linq - Entities</category></item><item><title>HashPassword Method for Entity Framework MVC3 Razor Custom Member Provider C# Using LINQ</title><link>https://weblogs.asp.net:443/nannettethacker/hashpassword-method-for-entity-framework-mvc3-razor-custom-member-provider-c-using-linq</link><description>From my &lt;a href="/nannettethacker/archive/2012/01/11/mvc3-razor-entity-framework-amp-linq-custom-membership-provider-with-custom-role-provider.aspx" target="_blank" mce_href="/nannettethacker/archive/2012/01/11/mvc3-razor-entity-framework-amp-linq-custom-membership-provider-with-custom-role-provider.aspx"&gt;C# MVC3 Razor Custom Membership Provider&lt;/a&gt; article and source code, here is the code for the HashPassword method. I welcome any suggestions for improvement.&lt;br&gt;&lt;font size="1"&gt;
&lt;pre&gt;// helper method
private byte[] HashPassword(string password)
{
    // NKT: This will only work with a new database, &lt;br&gt;    // otherwise existing passwords will be broken.
    // If you use this, be sure to set the saltvalue to your own &lt;br&gt;    // customization in the web.config file in your web app
    // &amp;lt;add key="SaltValue" value="*!ShiningStar!*" /&amp;gt;
    // This won't work with an existing database, as they won't have the salt value
    // so make sure you alter the password hash or encryption as needed for an existing database...
    CryptoProvider crypto = new CryptoProvider();
    byte[] hashedPassword = crypto.EncryptData(password.Trim());
    return hashedPassword;
}

public static string GetSaltValue()
{
    string saltValue = ConfigurationManager.AppSettings["SaltValue"];
    return saltValue;
}

public byte[] EncryptData(string dataString)
{

    // NKT: custom method using functionality from this article
    // http://www.4guysfromrolla.com/articles/103002-1.2.aspx
    // salting has value
    //http://www.4guysfromrolla.com/articles/112002-1.aspx
    // this isn't as secure as a unique salt per user, but if you use a unique salt per site, &lt;br&gt;    //at least they won't know that salt value if they steal the &lt;br&gt;    // database and not the web.config file
    // store the saltvalue in the web.config file. make unique per website.
    string saltedString = dataString + GetSaltValue();

    MD5CryptoServiceProvider md5Hasher = new MD5CryptoServiceProvider();
    byte[] hashedDataBytes = null;
    UTF8Encoding encoder = new UTF8Encoding();
    hashedDataBytes = md5Hasher.ComputeHash(encoder.GetBytes(saltedString));

    return hashedDataBytes;

}
&lt;/pre&gt;&lt;/font&gt;&lt;br&gt;&lt;font size="3"&gt;[SIGNATURE]&lt;/font&gt;</description><pubDate>Thu, 12 Jan 2012 20:51:00 GMT</pubDate><guid isPermaLink="true">https://weblogs.asp.net:443/nannettethacker/hashpassword-method-for-entity-framework-mvc3-razor-custom-member-provider-c-using-linq</guid><category>ASP.NET</category><category>C#</category><category>Custom MembershipProvider</category><category>Entity Framework</category><category>General Software Development</category><category>Linq - Entities</category></item><item><title>ValidateUser Method for Entity Framework MVC3 Razor Custom Member Provider C# Using LINQ</title><link>https://weblogs.asp.net:443/nannettethacker/validateuser-method-for-mvc3-razor-custom-member-provider-c</link><description>From my &lt;a href="/nannettethacker/archive/2012/01/11/mvc3-razor-entity-framework-amp-linq-custom-membership-provider-with-custom-role-provider.aspx" target="_blank" mce_href="/nannettethacker/archive/2012/01/11/mvc3-razor-entity-framework-amp-linq-custom-membership-provider-with-custom-role-provider.aspx"&gt;C# MVC3 Razor Custom Membership Provider&lt;/a&gt; article and source code, here is the code for the ValidateUser method. I welcome any suggestions for improvement.&lt;br&gt;
&lt;font size="1"&gt;
&lt;pre&gt;public override bool ValidateUser(string username, string password)
{
    // PasswordFormat = Hashed
    byte[] hashedPassword = &lt;a href="/nannettethacker/archive/2012/01/12/hashpassword-method-for-entity-framework-mvc3-razor-custom-member-provider-c-using-linq.aspx" mce_href="/nannettethacker/archive/2012/01/12/hashpassword-method-for-entity-framework-mvc3-razor-custom-member-provider-c-using-linq.aspx"&gt;HashPassword&lt;/a&gt;(password.Trim());
    // NKT: LINQ to Entities does not recognize 
    // the method 'Int32 ToInt32(System.Object)' method, 
    // and this method cannot be translated into a store expression.
    int userStatus = 
        Convert.ToInt32(SSS.GlobalListValues.Enums.UserStatusCode.Active);
    using (var context = new SSSEntities())
    {
        var query =
            from u in context.UserProfiles
            where u.UserName == username &amp;amp;&amp;amp;
            u.UserPassword == hashedPassword &amp;amp;&amp;amp;
                u.UserStatusCode == userStatus
            select u;

        bool isUserFound = false;
        foreach (var user in query.Take(1))
        {
            isUserFound = true;
        }
        return isUserFound;
    }
}
&lt;/pre&gt;&lt;/font&gt;
&lt;br&gt;
[SIGNATURE]</description><pubDate>Thu, 12 Jan 2012 16:30:00 GMT</pubDate><guid isPermaLink="true">https://weblogs.asp.net:443/nannettethacker/validateuser-method-for-mvc3-razor-custom-member-provider-c</guid><category>ASP.NET</category><category>C#</category><category>Custom MembershipProvider</category><category>Entity Framework</category><category>General Software Development</category><category>Linq - Entities</category></item><item><title> C# MVC3 Razor Entity Framework &amp; LINQ Custom Membership Provider with Custom Role Provider</title><link>https://weblogs.asp.net:443/nannettethacker/mvc3-razor-entity-framework-amp-linq-custom-membership-provider-with-custom-role-provider</link><description>&lt;p&gt; This C# project demonstrates how to create an MVC3 Razor Entity Framework &amp;amp; LINQ Custom Membership Provider with Custom Role Provider. 
    Perhaps you are working with a legacy database or you prefer working with a database that uses numeric identity keys instead of Guids. 
    The example UserProfile table in this project uses an integer UserId as the primary key and various other fields that aren't in the default ASP.NET User table. Use the Log On Link in the project and the Register link to create your own account.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;Source Code is here for &lt;a href="http://custommemberprovider.codeplex.com/releases/view/80360" mce_href="http://custommemberprovider.codeplex.com/releases/view/80360"&gt;ShiningStarMVC3WebApplication.zip&lt;/a&gt; 
&lt;br&gt;&lt;br&gt;
    The SSS.ShiningStarModel contains the Entity data model. 
    It has been setup to use the &lt;a href="http://visualstudiogallery.msdn.microsoft.com/23df0450-5677-4926-96cc-173d02752313/" target="_blank" mce_href="http://visualstudiogallery.msdn.microsoft.com/23df0450-5677-4926-96cc-173d02752313/"&gt;ADO.NET 
    Poco Entity Generator&lt;/a&gt; by right-clicking the model surface 
    and selecting "Add Code Generation Item." I use this because 
    &lt;a href="http://msdn.microsoft.com/en-us/library/gg696165(v=VS.103).aspx" target="_blank" mce_href="http://msdn.microsoft.com/en-us/library/gg696165(v=VS.103).aspx" tag="What's not supported"&gt;it supports&lt;/a&gt; 
    &lt;a href="http://msdn.microsoft.com/en-us/library/bb896297.aspx" target="_blank" mce_href="http://msdn.microsoft.com/en-us/library/bb896297.aspx"&gt;Compiled Queries&lt;/a&gt;, which you may wish to use in the future. &lt;br&gt;&lt;br&gt;
    The SSS.MemberProviders project contains our SSSMembershipProvider and SSSRoleProvider classes. This will replace the built-in providers. 
    These allow you to use all .NET functionality with your data model. These providers utilize the Entity model and LINQ commands. 
    Not all methods are implemented in these providers, but the main methods required for the LogOn, Register, and ChangePassword are.
    &lt;/p&gt;&lt;p&gt;The defaultProviders must be setup in the web.config:&lt;br&gt;&lt;br&gt;
    &lt;code&gt;&amp;lt;membership defaultProvider="SSS.MemberProviders.Providers.SSSMembershipProvider"&amp;gt;&lt;br&gt;
      &amp;lt;providers&amp;gt;&lt;br&gt;
        &amp;lt;clear/&amp;gt;&lt;br&gt;
        &amp;lt;add name="SSS.MemberProviders.Providers.SSSMembershipProvider" &lt;br&gt;
             type="SSS.MemberProviders.Providers.SSSMembershipProvider" &lt;br&gt;
             connectionStringName="ApplicationServices"&lt;br&gt;
             enablePasswordRetrieval="false" enablePasswordReset="true" &lt;br&gt;
             requiresQuestionAndAnswer="false" requiresUniqueEmail="true"&lt;br&gt;
             maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" &lt;br&gt;
             minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10"&lt;br&gt;
             description="Entity Framework MVC3 Custom Membership Provider by &lt;br&gt;
             Nannette Thacker http://www.shiningstar.net Shining Star Services LLC"&lt;br&gt;
              writeExceptionsToEventLog="false"&lt;br&gt;
             applicationName="/" /&amp;gt;&lt;br&gt;
      &amp;lt;/providers&amp;gt;&lt;br&gt;
    &amp;lt;/membership&amp;gt;&lt;/code&gt;
    &lt;br&gt;&lt;br&gt;
    Also add the role provider to the web.config&lt;br&gt;&lt;br&gt;
          &lt;code&gt;&amp;lt;roleManager defaultProvider="SSS.MemberProviders.Providers.SSSRoleProvider"&amp;gt;&lt;br&gt;
      &amp;lt;providers&amp;gt;&lt;br&gt;
        &amp;lt;clear/&amp;gt;&lt;br&gt;
          &amp;lt;add name="SSS.MemberProviders.Providers.SSSRoleProvider" &lt;br&gt;
          type="SSS.MemberProviders.Providers.SSSRoleProvider" &lt;br&gt;
          connectionStringName="ApplicationServices" applicationName="/" /&amp;gt;&lt;br&gt;
          &amp;lt;!--&amp;lt;add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" &lt;br&gt;
          connectionStringName="ApplicationServices" applicationName="/" 
          /&amp;gt;--&amp;gt;&lt;br&gt;
        &amp;lt;add name="AspNetWindowsTokenRoleProvider" &lt;br&gt;
        type="System.Web.Security.WindowsTokenRoleProvider" &lt;br&gt;
        applicationName="/" /&amp;gt;&lt;br&gt;
      &amp;lt;/providers&amp;gt;&lt;br&gt;
    &amp;lt;/roleManager&amp;gt;&lt;/code&gt;
    &lt;br&gt;&lt;br&gt;
    The ShiningStarMVC3Website was created from the MVC3 Razor template. 
    The Account LogOn, Register, and ChangePassword views are according to code generation. 
    The AccountModels.cs is also according to code generation. &lt;br&gt;&lt;br&gt;
    A ShiningStarMVC2012_2.sql file is included to generate the demo database and example records for the list values. 
    Be sure to search for 00.00.00.00 and update the IP address in the Web.config and App.Config files to your database IP address.&lt;br&gt;&lt;br&gt;
    Please check the References. When a project requires the EntityFramework reference, right click the Reference directory, 
    select Manage NuGet Packages.  Do an online search for EntityFramework and click to install it.&lt;br&gt;&lt;br&gt;
    The ListSet and ListValue tables contain data that is used to populate comboboxes and lists. 
    In our situation, it contains the possible User Roles. 
    The SSS.GlobalListValues project contains Enumerations from the ListSet and ListValue tables 
    so you can work with the values programmatically. 
    &lt;br&gt;&lt;br&gt;
    The SSS.GlobalUtilities project contains a CryptoProvider for hashing the password. 
    In the Web.config, setup a Salt value for your database: 
    &amp;lt;add key="SaltValue" value="*!ShiningStar!*" /&amp;gt;. 
    This will work fine for a new database, but if you are trying to connect to a legacy database 
    you will need to incorporate your current method of password hashing / encrypting, etc.
    &lt;br&gt;&lt;br&gt;
    I've also included Menu tables for future development. 
    I may add more screens for CRUD operations on the List and Menu tables in the future. The current project does not support those however.
    &lt;br&gt;&lt;br&gt;[SIGNATURE]&lt;/p&gt;</description><pubDate>Wed, 11 Jan 2012 22:22:00 GMT</pubDate><guid isPermaLink="true">https://weblogs.asp.net:443/nannettethacker/mvc3-razor-entity-framework-amp-linq-custom-membership-provider-with-custom-role-provider</guid><category>ASP.NET</category><category>C#</category><category>Custom MembershipProvider</category><category>Entity Framework</category><category>General Software Development</category><category>Linq - Entities</category><category>MVC3 Razor</category><category>Object Oriented Programming</category><category>SQL Server</category></item><item><title>C# Custom LinkedList Main() method - Learning C# - Part 7</title><link>https://weblogs.asp.net:443/nannettethacker/c-custom-linkedlist-main-method-learning-c-part-7</link><description>In Part 1 of this series, we created a console application and an abstract class. In Part 2 we setup our LinkedList derived class and defined our properties and setup our constructor. In Part 3, we defined our Push and Pop methods. We implemented both a PopLifo and PopFifo method. In part 4 we defined our PrintLifo method to print nodes from the top of the stack. We also discussed C# Operators. In Part 5 we defined a PrintFifo() method, which used a GetNode() helper method to find specific nodes, allowing us to print nodes from the bottom of the stack. In Part 6 we created a FindItems() method which printed a listing to the screen of all items based on the category or item name.&lt;br&gt;&lt;br&gt;In this final article, we will look at our Main() program and how to use our new LinkedList class.&lt;br&gt;&lt;br&gt;&lt;font size="1"&gt;
&lt;pre&gt;   class Program
   {
   static void Main(string[] args)
   {
   LinkedList ListItems = new LinkedList();
   ListItems.Push("Kitchen", "Dining Room Set");
   ListItems.Push("Living Category", "Sofa and Recliner");
   ListItems.Push("Living Category", "Stereo and Sound System");
   ListItems.Push("Electronics", "PS3");
   ListItems.Push("Electronics", "Wii");
   ListItems.Push("Electronics", "Nook");
   ListItems.Push("Electronics", "Big Screen TV");
   ListItems.PrintFifo();
   Console.WriteLine("Pop");
   ListItems.PopFifo();
   ListItems.PopLifo();
   ListItems.PrintLifo();
   ListItems.FindItems("Electronics");
   Console.ReadLine();
   }
   }
}&lt;/pre&gt;&lt;/font&gt;&lt;p&gt;&lt;br&gt;&lt;br&gt;When we create a console application, our Program class and Main() method are setup by default. Our Main() method is defined as a static method. The "static" keyword instructs the system to create only one instance of the method regardless of how many instances of its class are created.&lt;br&gt;&lt;br&gt;In our Main() method, we create a new LinkedList and name it ListItems. Rather than using this to create nodes, as we did with the Head and Next nodes which were also LinkedLists, we are going to use this to call the methods defined in the LinkedList class. When we type "ListItems." intellisense will kick in and display all public methods defined in our LinkedList class. Now we can use this to Push() inventory items to our list, PrintFifo() or PrintLifo(), PopFifo() or PopLifo(), and FindItems(). We want to follow up with Console.ReadLine(); to keep the text from zooping off the screen and returning to the program. Console.ReadLine(); will allows us to stop and wait for input, thus allowing us to see our results.&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;a href="http://weblogs.asp.net/blogs/nannettethacker/LL3.png" mce_href="http://weblogs.asp.net/blogs/nannettethacker/LL3.png"&gt;&lt;img border="0" src="http://weblogs.asp.net/blogs/nannettethacker/LL3.png" mce_src="https://aspblogs.blob.core.windows.net/media/nannettethacker/Media/LL3.png"&gt;&lt;/a&gt;&lt;br&gt;&lt;br&gt;In our example above, we print our items in LIFO order, then we remove the top and bottom nodes, then print our remaining items in FIFO order. Then we search for items in the "Electronics" category and display them to the screen. Play around with it, put in break points and step through the code and see what is happening.&lt;/p&gt;&lt;ul&gt;&lt;li&gt; &lt;a href="http://csharplinkedlist.codeplex.com/releases/view/80287" target="_blank"&gt;Download Source Code on CodePlex: CSLinkedList.zip&lt;/a&gt;&lt;/li&gt;&lt;li&gt; &lt;a href="http://weblogs.asp.net/nannettethacker/archive/2012/01/10/c-custom-linkedlist-console-application-and-abstract-base-class-and-method-learning-c-part-1.aspx"&gt;C# Custom LinkedList Console Application and Abstract Base Class and Method - Learning C# - Part 1&lt;/a&gt;&lt;/li&gt;&lt;li&gt; &lt;a href="http://weblogs.asp.net/nannettethacker/archive/2012/01/10/c-custom-linkedlist-derived-classes-constructor-initializations-learning-c-part-2.aspx"&gt;C# Custom LinkedList Derived Classes, Constructor Initializations - Learning C# - Part 2&lt;/a&gt;&lt;/li&gt;&lt;li&gt; &lt;a href="http://weblogs.asp.net/nannettethacker/archive/2012/01/10/c-custom-linkedlist-push-and-pop-methods-learning-c-part-3.aspx"&gt;C# Custom LinkedList Push and Pop Methods - Learning C# - Part 3&lt;/a&gt;&lt;/li&gt;&lt;li&gt; &lt;a href="http://weblogs.asp.net/nannettethacker/archive/2012/01/10/c-custom-linkedlist-printlifo-method-and-c-operators-learning-c-part-4.aspx"&gt;C# Custom LinkedList PrintLifo method and C# Operators - Learning C# - Part 4&lt;/a&gt;&lt;/li&gt;&lt;li&gt; &lt;a href="http://weblogs.asp.net/nannettethacker/archive/2012/01/10/c-custom-linkedlist-printfifo-method-and-getnode-by-position-learning-c-part-5.aspx"&gt;C# Custom LinkedList PrintFifo method and GetNode by Position - Learning C# - Part 5&lt;/a&gt;&lt;/li&gt;&lt;li&gt; &lt;a href="http://weblogs.asp.net/nannettethacker/archive/2012/01/10/c-custom-linkedlist-finditems-method-learning-c-part-6.aspx"&gt;C# Custom LinkedList FindItems() method - Learning C# - Part 6&lt;/a&gt;&lt;/li&gt;&lt;li&gt; &lt;a href="http://weblogs.asp.net/nannettethacker/archive/2012/01/10/c-custom-linkedlist-main-method-learning-c-part-7.aspx"&gt;C# Custom LinkedList Main() method - Learning C# - Part 7&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;[CSLINKEDLIST]&lt;br&gt;&lt;br&gt;&lt;/p&gt;</description><pubDate>Tue, 10 Jan 2012 18:00:00 GMT</pubDate><guid isPermaLink="true">https://weblogs.asp.net:443/nannettethacker/c-custom-linkedlist-main-method-learning-c-part-7</guid><category>ASP.NET</category><category>C#</category><category>General Software Development</category><category>Object Oriented Programming</category></item><item><title>C# Custom LinkedList FindItems() method - Learning C# - Part 6</title><link>https://weblogs.asp.net:443/nannettethacker/c-custom-linkedlist-finditems-method-learning-c-part-6</link><description>In Part 1 of this series, we created a console application and an abstract class. In Part 2 we setup our LinkedList derived class and defined our properties and setup our constructor. In Part 3, we defined our Push and Pop methods. We implemented both a PopLifo and PopFifo method. In part 4 we defined our PrintLifo method to print nodes from the top of the stack. We also discussed C# Operators. In Part 5 we defined a PrintFifo() method, which used a GetNode() helper method to find specific nodes, allowing us to print nodes from the bottom of the stack.&lt;br&gt;&lt;br&gt;In this article, we will create a FindItems() method which will print a listing to the screen of all items based on the category or item name.&lt;br&gt;&lt;br&gt;&lt;br&gt;
&lt;font size="1"&gt;
&lt;pre&gt;   public bool FindItems(string category, string item = "")
   {
   LinkedList CurrentNode = new LinkedList();
   bool boolSuccess = false;   // initialize
   if (category == "" &amp;amp;&amp;amp; item == "")
   {
   Console.WriteLine("\nYou must provide a category or item to begin the search.");
   return boolSuccess;
   }&lt;/pre&gt;&lt;/font&gt;First we define our FindItems method and pass the category by name. Our "item" parameter is an optional parameter, indicated so by defining the default value: '= ""'. This means that the user may pass in a value or not use it at all as in: FindItems(categoryname,itemname) vs. FindItems(categoryname).&lt;br&gt;&lt;br&gt;If our category and our item are both blank, we send a message to the screen and return to the calling method. If not, we write a message to the screen indicating that we are in search mode and what the two search criteria are.&lt;br&gt;&lt;br&gt;
&lt;font size="1"&gt;
&lt;pre&gt;   Console.WriteLine("\nSearch Criteria: '{0}' and '{1}'\n", category, item);
   for (CurrentNode = Head; CurrentNode != null; CurrentNode = CurrentNode.Next)
   {
   // if it finds the item or the category, print the item
   if ((CurrentNode.Item() == item) ||
   (CurrentNode.Category() == category))
   {
   Console.WriteLine("Found Category: {0} Item: {1}", &lt;br&gt;          CurrentNode.Category(), CurrentNode.Item());
   boolSuccess = true;
   }
   }
   return boolSuccess;
   }
}&lt;/pre&gt;&lt;/font&gt;&lt;p&gt;&lt;br&gt;&lt;br&gt;In this "for" loop, we start with the Head node, and as long as the node is not null, we loop through the nodes, reassigning our current node to the node as stored in the "Next" node. As we loop through the nodes, we see if the value of the item or category match the search criteria, and if so, we print the node values to the screen. If an item is found, we set the boolSuccess value to true and at the end of the method, we pass this back to the calling method.&lt;br&gt;&lt;br&gt;In our next article, we will look at our Main() program and how to use our new LinkedList class.&lt;/p&gt;&lt;ul&gt;&lt;li&gt; &lt;a href="http://csharplinkedlist.codeplex.com/releases/view/80287" target="_blank"&gt;Download Source Code on CodePlex: CSLinkedList.zip&lt;/a&gt;&lt;/li&gt;&lt;li&gt; &lt;a href="http://weblogs.asp.net/nannettethacker/archive/2012/01/10/c-custom-linkedlist-console-application-and-abstract-base-class-and-method-learning-c-part-1.aspx"&gt;C# Custom LinkedList Console Application and Abstract Base Class and Method - Learning C# - Part 1&lt;/a&gt;&lt;/li&gt;&lt;li&gt; &lt;a href="http://weblogs.asp.net/nannettethacker/archive/2012/01/10/c-custom-linkedlist-derived-classes-constructor-initializations-learning-c-part-2.aspx"&gt;C# Custom LinkedList Derived Classes, Constructor Initializations - Learning C# - Part 2&lt;/a&gt;&lt;/li&gt;&lt;li&gt; &lt;a href="http://weblogs.asp.net/nannettethacker/archive/2012/01/10/c-custom-linkedlist-push-and-pop-methods-learning-c-part-3.aspx"&gt;C# Custom LinkedList Push and Pop Methods - Learning C# - Part 3&lt;/a&gt;&lt;/li&gt;&lt;li&gt; &lt;a href="http://weblogs.asp.net/nannettethacker/archive/2012/01/10/c-custom-linkedlist-printlifo-method-and-c-operators-learning-c-part-4.aspx"&gt;C# Custom LinkedList PrintLifo method and C# Operators - Learning C# - Part 4&lt;/a&gt;&lt;/li&gt;&lt;li&gt; &lt;a href="http://weblogs.asp.net/nannettethacker/archive/2012/01/10/c-custom-linkedlist-printfifo-method-and-getnode-by-position-learning-c-part-5.aspx"&gt;C# Custom LinkedList PrintFifo method and GetNode by Position - Learning C# - Part 5&lt;/a&gt;&lt;/li&gt;&lt;li&gt; &lt;a href="http://weblogs.asp.net/nannettethacker/archive/2012/01/10/c-custom-linkedlist-finditems-method-learning-c-part-6.aspx"&gt;C# Custom LinkedList FindItems() method - Learning C# - Part 6&lt;/a&gt;&lt;/li&gt;&lt;li&gt; &lt;a href="http://weblogs.asp.net/nannettethacker/archive/2012/01/10/c-custom-linkedlist-main-method-learning-c-part-7.aspx"&gt;C# Custom LinkedList Main() method - Learning C# - Part 7&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;br&gt;[CSLINKEDLIST]&lt;/p&gt;</description><pubDate>Tue, 10 Jan 2012 17:50:00 GMT</pubDate><guid isPermaLink="true">https://weblogs.asp.net:443/nannettethacker/c-custom-linkedlist-finditems-method-learning-c-part-6</guid><category>ASP.NET</category><category>C#</category><category>General Software Development</category><category>Object Oriented Programming</category></item><item><title>C# Custom LinkedList PrintFifo method and GetNode by Position - Learning C# - Part 5</title><link>https://weblogs.asp.net:443/nannettethacker/c-custom-linkedlist-printfifo-method-and-getnode-by-position-learning-c-part-5</link><description>In Part 1 of this series, we created a console application and an abstract class. In Part 2 we setup our LinkedList derived class and defined our properties and setup our constructor. In Part 3, we defined our Push and Pop methods. We implemented both a PopLifo and PopFifo method. In part 4 we defined our PrintLifo method to print nodes from the top of the stack. We also discussed C# Operators.&lt;br&gt;&lt;br&gt;In this article we will define a PrintFifo() method, which will use a GetNode() helper method to find specific nodes, allowing us to print nodes from the bottom of the stack.&lt;br&gt;&lt;br&gt;To print our list in "first in first out" order, since our linked list contains pointers to the previously added node on the list, we have no direct means to access the first node on the list, so we will create a "GetNode()" method to find a specific node by position.&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;font size="1"&gt;
&lt;pre&gt;   private LinkedList GetNode(int position)
   {
   // traverse thru list until reach the node at the position passed in
   // loop until reach the position just before the position desired, 
   // and return the .Next node, which is the position desired
   LinkedList node = Head;  // start with the last item added
   for (int i = 1; i &amp;lt; position &amp;amp;&amp;amp; node != null; i++)
   node = node.Next;
   return node;
   }&lt;/pre&gt;&lt;/font&gt;&lt;br&gt;&lt;br&gt;Our GetNode method will return a LinkedList at the position passed in as a parameter. We create a new node, which we assign to the Head node. Then we loop, beginning at 1, until 1 is greater than the position passed in or our node is not null, and we increment our counter as we loop through nodes. With each loop, we reassign our node to the node stored in the node.Next. Once we hit the node just prior to the position desired, we assign our node to the node.Next value -- which is the desired node -- and we return our node.&lt;br&gt;&lt;br&gt;&lt;br&gt;
&lt;pre&gt;   public void PrintFifo()
   {
   for (int i = size; i &amp;gt; 0; i--)
   {
   LinkedList node = this.GetNode(i);
   Console.WriteLine("Category: {0} Item: {1}",
   node.Category(), node.Item());
   }
   }&lt;/pre&gt;&lt;p&gt;&lt;br&gt;&lt;br&gt;Now we are ready to use the GetNode() method in our PrintFifo() method to print our list in "first in first out" order. Again, we use a "for" loop to loop through the nodes beginning with the node at the bottom of the stack -- the one in our linked list "size." We create a new node and assign it to the value returned from GetNode(i).&lt;br&gt;&lt;br&gt;We then utilize the &lt;a title="Console.WriteLine Method " href="http://msdn.microsoft.com/en-us/library/system.console.writeline(v=VS.100).aspx" target="_blank" mce_href="http://msdn.microsoft.com/en-us/library/system.console.writeline(v=VS.100).aspx"&gt;Console.WriteLine() method&lt;/a&gt; to print our values to the screen. Utilizing {0} {1} etc. allows us to leave a placeholder for the values following the string you want printed. In our example, the category name retrieved from the node.Category() method will print in the {0} position and the value retrieved from the node.Item() method wil print in the {1} position.&lt;br&gt;&lt;br&gt;In our next article, we will create a FindItems() method which will print a listing to the screen of all items based on the category or item name.&lt;/p&gt;&lt;ul&gt;&lt;li&gt; &lt;a href="http://csharplinkedlist.codeplex.com/releases/view/80287" target="_blank"&gt;Download Source Code on CodePlex: CSLinkedList.zip&lt;/a&gt;&lt;/li&gt;&lt;li&gt; &lt;a href="http://weblogs.asp.net/nannettethacker/archive/2012/01/10/c-custom-linkedlist-console-application-and-abstract-base-class-and-method-learning-c-part-1.aspx"&gt;C# Custom LinkedList Console Application and Abstract Base Class and Method - Learning C# - Part 1&lt;/a&gt;&lt;/li&gt;&lt;li&gt; &lt;a href="http://weblogs.asp.net/nannettethacker/archive/2012/01/10/c-custom-linkedlist-derived-classes-constructor-initializations-learning-c-part-2.aspx"&gt;C# Custom LinkedList Derived Classes, Constructor Initializations - Learning C# - Part 2&lt;/a&gt;&lt;/li&gt;&lt;li&gt; &lt;a href="http://weblogs.asp.net/nannettethacker/archive/2012/01/10/c-custom-linkedlist-push-and-pop-methods-learning-c-part-3.aspx"&gt;C# Custom LinkedList Push and Pop Methods - Learning C# - Part 3&lt;/a&gt;&lt;/li&gt;&lt;li&gt; &lt;a href="http://weblogs.asp.net/nannettethacker/archive/2012/01/10/c-custom-linkedlist-printlifo-method-and-c-operators-learning-c-part-4.aspx"&gt;C# Custom LinkedList PrintLifo method and C# Operators - Learning C# - Part 4&lt;/a&gt;&lt;/li&gt;&lt;li&gt; &lt;a href="http://weblogs.asp.net/nannettethacker/archive/2012/01/10/c-custom-linkedlist-printfifo-method-and-getnode-by-position-learning-c-part-5.aspx"&gt;C# Custom LinkedList PrintFifo method and GetNode by Position - Learning C# - Part 5&lt;/a&gt;&lt;/li&gt;&lt;li&gt; &lt;a href="http://weblogs.asp.net/nannettethacker/archive/2012/01/10/c-custom-linkedlist-finditems-method-learning-c-part-6.aspx"&gt;C# Custom LinkedList FindItems() method - Learning C# - Part 6&lt;/a&gt;&lt;/li&gt;&lt;li&gt; &lt;a href="http://weblogs.asp.net/nannettethacker/archive/2012/01/10/c-custom-linkedlist-main-method-learning-c-part-7.aspx"&gt;C# Custom LinkedList Main() method - Learning C# - Part 7&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;[CSLINKEDLIST]&lt;br&gt;&lt;br&gt;&lt;/p&gt;</description><pubDate>Tue, 10 Jan 2012 17:49:00 GMT</pubDate><guid isPermaLink="true">https://weblogs.asp.net:443/nannettethacker/c-custom-linkedlist-printfifo-method-and-getnode-by-position-learning-c-part-5</guid></item><item><title>C# Custom LinkedList PrintLifo method and C# Operators - Learning C# - Part 4</title><link>https://weblogs.asp.net:443/nannettethacker/c-custom-linkedlist-printlifo-method-and-c-operators-learning-c-part-4</link><description>In Part 1 of this series, we created a console application and an abstract class. In Part 2 we setup our LinkedList derived class and defined our properties and setup our constructor. In Part 3, we defined our Push and Pop methods. We implemented both a PopLifo and PopFifo method.&lt;br&gt;&lt;br&gt;In this article, we define our PrintLifo method to print nodes from the top of the stack. We will also define a PrintFifo method, which will use a GetNode helper method to find specific nodes, allowing us to print nodes from the bottom of the stack.&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;pre&gt;   public void PrintLifo()
   {
   LinkedList node = Head;
   for (int i = size; i &amp;gt; 0 &amp;amp;&amp;amp; node != null; i--)
   {
   Console.WriteLine("Category: {0} Item: {1}",
   node.Category(), node.Item());
   node = node.Next;
   }
   }&lt;/pre&gt;&lt;br&gt;&lt;br&gt;In our above PrintLife() method, we create a new node, and assign it to our existing Head node. We will use a for statement to loop through our nodes, finding the previous node by using the "node.Next" value.&lt;br&gt;&lt;br&gt;&lt;pre&gt;   for (int i = size; i &amp;gt; 0 &amp;amp;&amp;amp; node != null; i--)&lt;/pre&gt;&lt;br&gt;&lt;br&gt;In our "for" loop, we define a new integer value "i" and set it to the size of our linked list. We then loop as long as "i" is greater than 0 and the node is not null or empty. On each loop we decrement our counter with "i--." In this one statement we are making use of assignment operators: i = size and i--. We are also using the relational operator "&amp;gt;" to see if "i" is greater than 0. And we are using the equality operator "!=" to see if the node is null or  not.&lt;br&gt;&lt;br&gt;C# uses several such operators. Think of the word: CREAM.&lt;br&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;Conditional Operators&lt;/td&gt;&lt;td&gt;&amp;amp;&amp;amp;, ||&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Relational Operators&lt;/td&gt;&lt;td&gt; &amp;lt;, &amp;gt;, &amp;lt;=, &amp;gt;=&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Equality Operators&lt;/td&gt;&lt;td&gt;==, !=&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Assignment Operators&lt;/td&gt;&lt;td&gt;=, +=, -=, *=, /=&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Mathematical Operators&lt;/td&gt;&lt;td&gt;+, -, *, /&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;&lt;br&gt;In our next article we will print our linked list in first in first out order and create a helper method GetNode() which allows us to retrieve a specific node by position.&lt;/p&gt;&lt;ul&gt;&lt;li&gt; &lt;a href="http://csharplinkedlist.codeplex.com/releases/view/80287" target="_blank"&gt;Download Source Code on CodePlex: CSLinkedList.zip&lt;/a&gt;&lt;/li&gt;&lt;li&gt; &lt;a href="http://weblogs.asp.net/nannettethacker/archive/2012/01/10/c-custom-linkedlist-console-application-and-abstract-base-class-and-method-learning-c-part-1.aspx"&gt;C# Custom LinkedList Console Application and Abstract Base Class and Method - Learning C# - Part 1&lt;/a&gt;&lt;/li&gt;&lt;li&gt; &lt;a href="http://weblogs.asp.net/nannettethacker/archive/2012/01/10/c-custom-linkedlist-derived-classes-constructor-initializations-learning-c-part-2.aspx"&gt;C# Custom LinkedList Derived Classes, Constructor Initializations - Learning C# - Part 2&lt;/a&gt;&lt;/li&gt;&lt;li&gt; &lt;a href="http://weblogs.asp.net/nannettethacker/archive/2012/01/10/c-custom-linkedlist-push-and-pop-methods-learning-c-part-3.aspx"&gt;C# Custom LinkedList Push and Pop Methods - Learning C# - Part 3&lt;/a&gt;&lt;/li&gt;&lt;li&gt; &lt;a href="http://weblogs.asp.net/nannettethacker/archive/2012/01/10/c-custom-linkedlist-printlifo-method-and-c-operators-learning-c-part-4.aspx"&gt;C# Custom LinkedList PrintLifo method and C# Operators - Learning C# - Part 4&lt;/a&gt;&lt;/li&gt;&lt;li&gt; &lt;a href="http://weblogs.asp.net/nannettethacker/archive/2012/01/10/c-custom-linkedlist-printfifo-method-and-getnode-by-position-learning-c-part-5.aspx"&gt;C# Custom LinkedList PrintFifo method and GetNode by Position - Learning C# - Part 5&lt;/a&gt;&lt;/li&gt;&lt;li&gt; &lt;a href="http://weblogs.asp.net/nannettethacker/archive/2012/01/10/c-custom-linkedlist-finditems-method-learning-c-part-6.aspx"&gt;C# Custom LinkedList FindItems() method - Learning C# - Part 6&lt;/a&gt;&lt;/li&gt;&lt;li&gt; &lt;a href="http://weblogs.asp.net/nannettethacker/archive/2012/01/10/c-custom-linkedlist-main-method-learning-c-part-7.aspx"&gt;C# Custom LinkedList Main() method - Learning C# - Part 7&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;[CSLINKEDLIST]&lt;br&gt;&lt;/p&gt;</description><pubDate>Tue, 10 Jan 2012 17:46:00 GMT</pubDate><guid isPermaLink="true">https://weblogs.asp.net:443/nannettethacker/c-custom-linkedlist-printlifo-method-and-c-operators-learning-c-part-4</guid><category>ASP.NET</category><category>C#</category><category>General Software Development</category><category>Object Oriented Programming</category></item><item><title>C# Custom LinkedList Push and Pop Methods - Learning C# - Part 3</title><link>https://weblogs.asp.net:443/nannettethacker/c-custom-linkedlist-push-and-pop-methods-learning-c-part-3</link><description>In Part 1 of this series, we created a console application and an abstract class. In Part 2 we setup our LinkedList derived class and defined our properties and setup our constructor.&lt;br&gt;&lt;br&gt;In this article, we define our Push and Pop methods. Our Push method allows us to add an Inventory item to our list on the top of the stack. We define PopLifo and PopFifo (last in first out and first in first out) methods.&lt;br&gt;&lt;br&gt;
&lt;font size="1"&gt;
&lt;pre&gt;   public int Push(string invCategory, string invItem)
   {
   // add the Inventory to the list
   LinkedList node = new LinkedList();
   node.inventoryCategory = invCategory;
   node.inventoryItem = invItem;
   node.Next = Head;  // set the Next pointer to the 
   // last item previously added
   Head = node;   // set the Head as the item just now added
   return size++;  // increment the size of the list
   }&lt;/pre&gt;&lt;/font&gt;&lt;br&gt;&lt;br&gt;We create our Push method as public, and it returns the size of our list as an integer. We pass two parameters to our method: the category and item. &lt;br&gt;&lt;br&gt;In our first statement, we create a new "node." Since we are making it a LinkedList type, that means it consists of its own category, item, and Next value. In our next statement, as we type the word "node." intellisense provides the different properties defined in the LinkedList, thus allowing us to easily populate these items. We set our node.inventoryCategory value, etc.&lt;br&gt;&lt;br&gt;Our node.Next is assigned to our previously added node as stored in "Head." And our Head node is reassigned with the values we just entered.&lt;br&gt;&lt;br&gt;We increment our size counter and return the value.&lt;br&gt;&lt;br&gt;In our Pop methods, we aren't actually "deleting" anything. Let's take a look:&lt;br&gt;&lt;br&gt;
&lt;font size="1"&gt;
&lt;pre&gt;   public void PopLifo()   // LIFO
   {
   if (size &amp;gt; 0)
   {
   LinkedList node = Head;
   Head = node.Next;   // assign pointer to the head to the previous second node
   size--;   // decrement the counter
   }
   }&lt;/pre&gt;&lt;/font&gt;&lt;br&gt;In our PopLifo method, we remove the last node added to the list. To do so, we first want to see if our size is greater than zero, using the "&amp;gt;" relational operator. If so, we create a new node and assign it to our "Head." We then reassign our Head, or top of the list, to point to the node that Head was pointing to, our "node.Next." Then we decrement our size of our list.&lt;br&gt;&lt;br&gt;&lt;font size="1"&gt;
&lt;pre&gt;   public void PopFifo()
   {
   if (size &amp;gt; 0)   // don't allow to keep decrementing counter if list is empty
   size--;   // decrement the counter to remove it from displaying in the list (won't traverse to this node)
   }&lt;/pre&gt;&lt;/font&gt;&lt;p&gt;&lt;br&gt;Removing our node from the "first in" node on the list is much simpler. We simply decrement our size by one so that when we traverse through the nodes we never hit it.&lt;br&gt;&lt;br&gt;In Part 4 of our series we will Print our list to the screen.&lt;/p&gt;&lt;ul&gt;&lt;li&gt; &lt;a href="http://csharplinkedlist.codeplex.com/releases/view/80287" target="_blank"&gt;Download Source Code on CodePlex: CSLinkedList.zip&lt;/a&gt;&lt;/li&gt;&lt;li&gt; &lt;a href="http://weblogs.asp.net/nannettethacker/archive/2012/01/10/c-custom-linkedlist-console-application-and-abstract-base-class-and-method-learning-c-part-1.aspx"&gt;C# Custom LinkedList Console Application and Abstract Base Class and Method - Learning C# - Part 1&lt;/a&gt;&lt;/li&gt;&lt;li&gt; &lt;a href="http://weblogs.asp.net/nannettethacker/archive/2012/01/10/c-custom-linkedlist-derived-classes-constructor-initializations-learning-c-part-2.aspx"&gt;C# Custom LinkedList Derived Classes, Constructor Initializations - Learning C# - Part 2&lt;/a&gt;&lt;/li&gt;&lt;li&gt; &lt;a href="http://weblogs.asp.net/nannettethacker/archive/2012/01/10/c-custom-linkedlist-push-and-pop-methods-learning-c-part-3.aspx"&gt;C# Custom LinkedList Push and Pop Methods - Learning C# - Part 3&lt;/a&gt;&lt;/li&gt;&lt;li&gt; &lt;a href="http://weblogs.asp.net/nannettethacker/archive/2012/01/10/c-custom-linkedlist-printlifo-method-and-c-operators-learning-c-part-4.aspx"&gt;C# Custom LinkedList PrintLifo method and C# Operators - Learning C# - Part 4&lt;/a&gt;&lt;/li&gt;&lt;li&gt; &lt;a href="http://weblogs.asp.net/nannettethacker/archive/2012/01/10/c-custom-linkedlist-printfifo-method-and-getnode-by-position-learning-c-part-5.aspx"&gt;C# Custom LinkedList PrintFifo method and GetNode by Position - Learning C# - Part 5&lt;/a&gt;&lt;/li&gt;&lt;li&gt; &lt;a href="http://weblogs.asp.net/nannettethacker/archive/2012/01/10/c-custom-linkedlist-finditems-method-learning-c-part-6.aspx"&gt;C# Custom LinkedList FindItems() method - Learning C# - Part 6&lt;/a&gt;&lt;/li&gt;&lt;li&gt; &lt;a href="http://weblogs.asp.net/nannettethacker/archive/2012/01/10/c-custom-linkedlist-main-method-learning-c-part-7.aspx"&gt;C# Custom LinkedList Main() method - Learning C# - Part 7&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;br&gt;[CSLINKEDLIST]&lt;br&gt;&lt;br&gt;&lt;/p&gt;</description><pubDate>Tue, 10 Jan 2012 17:43:00 GMT</pubDate><guid isPermaLink="true">https://weblogs.asp.net:443/nannettethacker/c-custom-linkedlist-push-and-pop-methods-learning-c-part-3</guid><category>ASP.NET</category><category>C#</category><category>General Software Development</category><category>Object Oriented Programming</category></item><item><title>C# Custom LinkedList Derived Classes, Constructor Initializations - Learning C# - Part 2</title><link>https://weblogs.asp.net:443/nannettethacker/c-custom-linkedlist-derived-classes-constructor-initializations-learning-c-part-2</link><description>In Part 1 of this series, we created a console application and an abstract class. In this article we will setup our LinkedList derived class and define our properties and setup our constructor.&lt;br&gt;&lt;br&gt;To allow our derived class to inherit from our Inventory class, after defining the LinkedList class, we add a colon and the name of the base class "Inventory." Upon typing the word "Inventory" from the keyboard, type "Ctrl" + "." -- this key combination opens up a drop down asking you to "Implement abstract class Inventory." Select that option and your class is created with the base class overrideable methods, in this case "Category."&lt;br&gt;&lt;br&gt;
&lt;pre&gt;   public class LinkedList : Inventory
   {
   public override string Category()
   {
   throw new NotImplementedException();
   }
   }&lt;/pre&gt;&lt;br&gt;&lt;br&gt;We define a private string inventoryCategory, to hold our assigned values. When we need to retrieve these values, we use the Category method. On your own, do some research on using Get/Set Properties instead of methods.&lt;br&gt;&lt;br&gt;&lt;font size="1"&gt;
&lt;pre&gt;   public class LinkedList : Inventory
   {
   // custom linked list
   private string inventoryCategory;
   public override string Category()
   {
   return inventoryCategory;
   }
   
   // self-referencing members (same name as its class)
   private LinkedList Head;   // pointer to the top of the stack
   // the last node added to the list
   private LinkedList Next;   // index to locate an item in the list
   private int size;   // how many records in the list
   public LinkedList()   // constructor / default values
   {
   Head = null;   // no items have been added 
   Next = null;
   inventoryCategory = string.Empty;
   size = 0;  // 1 based - list starts out as empty
   }&lt;/pre&gt;&lt;/font&gt;&lt;p&gt;&lt;br&gt;&lt;br&gt;We create two self-referencing members, meaning the type is the same name as their class: "private LinkedList Head" and "private LinkedList Next". The first points to the most recent node added to the list or the top of the stack. The second points to the next node on the list that was just previously added so that we can traverse through the list. Once we traverse to the next node, it again has its own Next node, to point to the previous node, and so forth.&lt;br&gt;&lt;br&gt;The "private int size" statement defines an integer used to keep track of how many records are in the list.&lt;br&gt;&lt;br&gt;Next we define our &lt;a title="Constructors (C# Programming Guide)" href="http://msdn.microsoft.com/en-us/library/ace5hbzh.aspx" target="_blank" mce_href="http://msdn.microsoft.com/en-us/library/ace5hbzh.aspx"&gt;constructor&lt;/a&gt;: "public LinkedList()." "&lt;a title="Constructors (C# Programming Guide)" href="http://msdn.microsoft.com/en-us/library/ace5hbzh.aspx" target="_blank" mce_href="http://msdn.microsoft.com/en-us/library/ace5hbzh.aspx"&gt;Constructors&lt;/a&gt;: are class methods that are executed when an object of a class or struct is created. They have the same name as the class or struct, and usually initialize the data members of the new object."&lt;br&gt;&lt;br&gt;True to our definition, we initialize the Head and Next to null. We set our inventoryCategory to empty using "string.Empty."  We could have just as easily set our inventoryCategory to empty by assigning it a value of "" (2 quote marks). &lt;br&gt;&lt;br&gt;We set our size to 0. Our list will be 1 based and increment to 1 when the first node is added.&lt;br&gt;&lt;br&gt;In Part 3 of our series, we will define our Push and Pop methods.&lt;/p&gt;&lt;ul&gt;&lt;li&gt; &lt;a href="http://csharplinkedlist.codeplex.com/releases/view/80287" target="_blank"&gt;Download Source Code on CodePlex: CSLinkedList.zip&lt;/a&gt;&lt;/li&gt;&lt;li&gt; &lt;a href="http://weblogs.asp.net/nannettethacker/archive/2012/01/10/c-custom-linkedlist-console-application-and-abstract-base-class-and-method-learning-c-part-1.aspx"&gt;C# Custom LinkedList Console Application and Abstract Base Class and Method - Learning C# - Part 1&lt;/a&gt;&lt;/li&gt;&lt;li&gt; &lt;a href="http://weblogs.asp.net/nannettethacker/archive/2012/01/10/c-custom-linkedlist-derived-classes-constructor-initializations-learning-c-part-2.aspx"&gt;C# Custom LinkedList Derived Classes, Constructor Initializations - Learning C# - Part 2&lt;/a&gt;&lt;/li&gt;&lt;li&gt; &lt;a href="http://weblogs.asp.net/nannettethacker/archive/2012/01/10/c-custom-linkedlist-push-and-pop-methods-learning-c-part-3.aspx"&gt;C# Custom LinkedList Push and Pop Methods - Learning C# - Part 3&lt;/a&gt;&lt;/li&gt;&lt;li&gt; &lt;a href="http://weblogs.asp.net/nannettethacker/archive/2012/01/10/c-custom-linkedlist-printlifo-method-and-c-operators-learning-c-part-4.aspx"&gt;C# Custom LinkedList PrintLifo method and C# Operators - Learning C# - Part 4&lt;/a&gt;&lt;/li&gt;&lt;li&gt; &lt;a href="http://weblogs.asp.net/nannettethacker/archive/2012/01/10/c-custom-linkedlist-printfifo-method-and-getnode-by-position-learning-c-part-5.aspx"&gt;C# Custom LinkedList PrintFifo method and GetNode by Position - Learning C# - Part 5&lt;/a&gt;&lt;/li&gt;&lt;li&gt; &lt;a href="http://weblogs.asp.net/nannettethacker/archive/2012/01/10/c-custom-linkedlist-finditems-method-learning-c-part-6.aspx"&gt;C# Custom LinkedList FindItems() method - Learning C# - Part 6&lt;/a&gt;&lt;/li&gt;&lt;li&gt; &lt;a href="http://weblogs.asp.net/nannettethacker/archive/2012/01/10/c-custom-linkedlist-main-method-learning-c-part-7.aspx"&gt;C# Custom LinkedList Main() method - Learning C# - Part 7&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;br&gt;[CSLINKEDLIST]&lt;br&gt;&lt;/p&gt;</description><pubDate>Tue, 10 Jan 2012 17:40:00 GMT</pubDate><guid isPermaLink="true">https://weblogs.asp.net:443/nannettethacker/c-custom-linkedlist-derived-classes-constructor-initializations-learning-c-part-2</guid><category>ASP.NET</category><category>C#</category><category>General Software Development</category><category>Object Oriented Programming</category></item><item><title>C# Custom LinkedList Console Application and Abstract Base Class and Method - Learning C# - Part 1</title><link>https://weblogs.asp.net:443/nannettethacker/c-custom-linkedlist-console-application-and-abstract-base-class-and-method-learning-c-part-1</link><description>One of the best ways to learn a new technology is by using it. In this tutorial, you will create a base class or abstract class, a derived or inherited class. You will work with self-referencing members, a constructor, if statements, for loops, null values, conditional operators, mathematical operators, relational operators, equality operators, and assignment operators. These concepts are quite basic to programming, but if you're learning, they're new to you.&lt;br&gt;&lt;br&gt;In our example we will create an abstract Inventory class. The Inventory class will have two functions: Category and Item. We will create a derived class, LinkedList, that uses the Inventory class as a linked list. This class will use custom methods, not built-in methods. In the LinkedList class we will create methods to add inventory items to the linked list, as well as remove them from the top of the stack or the bottom of the stack. We will also create methods to print in forward or reverse orders. And finally, we will create a method to allow searching the list by category or item and display the search results.&lt;br&gt;&lt;br&gt;First, let's create a console application. In Visual Studio, select File, New, and Project. Select the Visual C# category and the Console Application option.&lt;br&gt;&lt;br&gt;Name your project CSLinkedList and the solution name CSLinkedList. If you select the checkbox to "Create directory for solution," a new directory named CSLinkedList will be created, otherwise, your solution will be put inside the Location you designate.&lt;br&gt;&lt;br&gt;
&lt;a href="http://weblogs.asp.net/blogs/nannettethacker/LL1.png"&gt;&lt;img style="width: 700px; height: 485px;" border="0" src="https://aspblogs.blob.core.windows.net/media/nannettethacker/Media/LL1.png"&gt;&lt;/a&gt;&lt;br&gt;
&lt;br&gt;&lt;br&gt;
&lt;pre&gt;using System;
namespace CSLinkedList
{&lt;/pre&gt;&lt;br&gt;At the top of our project, you will see we need one .NET component, System. That is referenced by default when your project is created. If you open up the References list in the project explorer, you will see the list of libraries that are included by default. These add .NET framework functionality to your project.&lt;br&gt;&lt;br&gt;&lt;a href="http://weblogs.asp.net/blogs/nannettethacker/ll2.png"&gt;&lt;img border="0" src="https://aspblogs.blob.core.windows.net/media/nannettethacker/Media/ll2.png"&gt;&lt;/a&gt;&lt;br&gt;&lt;br&gt;A &lt;a title="namespace (C# Reference)" href="http://msdn.microsoft.com/en-us/library/z2kcy19k(v=VS.100).aspx" target="_blank" mce_href="http://msdn.microsoft.com/en-us/library/z2kcy19k(v=VS.100).aspx"&gt;namespace&lt;/a&gt; has been created by default. Namespaces help organize your code and provide a way to create globally unique types.&lt;br&gt;
&lt;pre&gt;   public abstract class Inventory
   {
   public abstract string Category();
   public string inventoryItem = string.Empty;
   public string Item()
   {
   return inventoryItem;
   }
   }&lt;/pre&gt;
&lt;p&gt;&lt;br&gt;One of the key concepts of &lt;a title="Object Oriented Programming Guidebook in ASP.NET (OOP)" href="http://weblogs.asp.net/nannettethacker/archive/2011/12/08/object-oriented-programming-guidebook-in-asp-net-oop.aspx" target="_blank" mce_href="http://weblogs.asp.net/nannettethacker/archive/2011/12/08/object-oriented-programming-guidebook-in-asp-net-oop.aspx"&gt;object oriented programming&lt;/a&gt; is Inheritance along with Abstraction. Inheritance allows you to create a class that allows you to reuse behaviors and definitions.&lt;br&gt;&lt;br&gt;We first want to create a base class, Inventory. That means that it is a parent class. To make the Inventory class a base class, we use the keyword "abstract." This means any abstract methods defined in the base class must be implemented in the inherited or derived class. If you do not wish to require implementation, use the "virtual" keyword which means that the derived class "can" override the method with its own implementation, but does not have to.&lt;br&gt;&lt;br&gt;In our above example, we have an abstract method "Category" and an implemented string and method: inventoryItem and Item(). Notice we do not define an implementation for the Category() method. The implementation must be defined by the derived class.&lt;br&gt; &lt;br&gt;Our linked list will use the Item() and Category() for retrieving our Inventory item names.&lt;br&gt;&lt;br&gt;In Part 2 of our series, we will setup our LinkedList derived class and define our properties and setup our constructor.&lt;/p&gt;


&lt;ul&gt;
    &lt;li&gt; &lt;a href="http://csharplinkedlist.codeplex.com/releases/view/80287" target="_blank"&gt;Download Source Code on CodePlex: CSLinkedList.zip&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt; &lt;a href="http://weblogs.asp.net/nannettethacker/archive/2012/01/10/c-custom-linkedlist-console-application-and-abstract-base-class-and-method-learning-c-part-1.aspx"&gt;C# Custom LinkedList Console Application and Abstract Base Class and Method - Learning C# - Part 1&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt; &lt;a href="http://weblogs.asp.net/nannettethacker/archive/2012/01/10/c-custom-linkedlist-derived-classes-constructor-initializations-learning-c-part-2.aspx"&gt;C# Custom LinkedList Derived Classes, Constructor Initializations - Learning C# - Part 2&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt; &lt;a href="http://weblogs.asp.net/nannettethacker/archive/2012/01/10/c-custom-linkedlist-push-and-pop-methods-learning-c-part-3.aspx"&gt;C# Custom LinkedList Push and Pop Methods - Learning C# - Part 3&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt; &lt;a href="http://weblogs.asp.net/nannettethacker/archive/2012/01/10/c-custom-linkedlist-printlifo-method-and-c-operators-learning-c-part-4.aspx"&gt;C# Custom LinkedList PrintLifo method and C# Operators - Learning C# - Part 4&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt; &lt;a href="http://weblogs.asp.net/nannettethacker/archive/2012/01/10/c-custom-linkedlist-printfifo-method-and-getnode-by-position-learning-c-part-5.aspx"&gt;C# Custom LinkedList PrintFifo method and GetNode by Position - Learning C# - Part 5&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt; &lt;a href="http://weblogs.asp.net/nannettethacker/archive/2012/01/10/c-custom-linkedlist-finditems-method-learning-c-part-6.aspx"&gt;C# Custom LinkedList FindItems() method - Learning C# - Part 6&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt; &lt;a href="http://weblogs.asp.net/nannettethacker/archive/2012/01/10/c-custom-linkedlist-main-method-learning-c-part-7.aspx"&gt;C# Custom LinkedList Main() method - Learning C# - Part 7&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;[CSLINKEDLIST]&lt;/p&gt;
</description><pubDate>Tue, 10 Jan 2012 17:30:00 GMT</pubDate><guid isPermaLink="true">https://weblogs.asp.net:443/nannettethacker/c-custom-linkedlist-console-application-and-abstract-base-class-and-method-learning-c-part-1</guid><category>ASP.NET</category><category>C#</category><category>General Software Development</category><category>Object Oriented Programming</category></item></channel></rss>