Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WPF
  4. C# Client Server Application on WPF IDE

C# Client Server Application on WPF IDE

Scheduled Pinned Locked Moved WPF
csharphelpvisual-studiowpfsysadmin
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    LAPEC
    wrote on last edited by
    #1

    Hello Everyone I have created a Client/Server application on C# on WPF IDE and I have a little problem on my UserClient property class... Within this class I have a method called:

    public override bool Equals(object obj)
    {
    UserClient temp = obj as UserClient;
    if (temp != null)
    {
    return (userId == temp.userId);
    }
    if (temp != null)
    {
    return (userPass == temp.userPass);
    }
    return false;
    }

    The problem I'm having is: The class UserClient is highlighted with a green line under-neath where when I place MouseOver it sas: UserClient overrides Object.Equals but does not override Object.GetHashCode Here is the entire UserClient class code:

    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.Data;
    using System.Diagnostics;

    namespace DtposClient
    {
    public class UserClient
    {
    // User Client Global variables
    // ====================================
    private string UserFullName;
    private string UserAccessLevel;
    private int UserId;
    private int UserPassword;

    public string fullName
        {
            get { return UserFullName; }
            set { UserFullName = value; }
    }
    
        public string accLevel
        {
            get { return UserAccessLevel; }
            set { UserAccessLevel = value; }
        }
    
        public int userId
        {
            get { return UserId; }
            set { UserId = value; }
        }
        
    public int userPass 
        {
            get { return UserPassword; }
            set { UserPassword = value; }
        }
        
    public override bool Equals(object obj)
    {
            UserClient temp = obj as UserClient;
            if (temp != null)
            {
                return (userId == temp.userId);
            }
            if (temp != null)
            {
                return (userPass == temp.userPass);
            }
            return false;
    }
    
        public UserClient(string fullNam, string aLevel, int usId, int pass)
    {
            fullName = fullNam;
            accLevel = aLevel;
            userId = usId;
            userPass = pass;
    }
    }
    

    }

    Could someone please help me crack this problem.... thanks in advance kind regards lapeci

    R P A 3 Replies Last reply
    0
    • L LAPEC

      Hello Everyone I have created a Client/Server application on C# on WPF IDE and I have a little problem on my UserClient property class... Within this class I have a method called:

      public override bool Equals(object obj)
      {
      UserClient temp = obj as UserClient;
      if (temp != null)
      {
      return (userId == temp.userId);
      }
      if (temp != null)
      {
      return (userPass == temp.userPass);
      }
      return false;
      }

      The problem I'm having is: The class UserClient is highlighted with a green line under-neath where when I place MouseOver it sas: UserClient overrides Object.Equals but does not override Object.GetHashCode Here is the entire UserClient class code:

      using System;
      using System.Collections;
      using System.Collections.Generic;
      using System.Data;
      using System.Diagnostics;

      namespace DtposClient
      {
      public class UserClient
      {
      // User Client Global variables
      // ====================================
      private string UserFullName;
      private string UserAccessLevel;
      private int UserId;
      private int UserPassword;

      public string fullName
          {
              get { return UserFullName; }
              set { UserFullName = value; }
      }
      
          public string accLevel
          {
              get { return UserAccessLevel; }
              set { UserAccessLevel = value; }
          }
      
          public int userId
          {
              get { return UserId; }
              set { UserId = value; }
          }
          
      public int userPass 
          {
              get { return UserPassword; }
              set { UserPassword = value; }
          }
          
      public override bool Equals(object obj)
      {
              UserClient temp = obj as UserClient;
              if (temp != null)
              {
                  return (userId == temp.userId);
              }
              if (temp != null)
              {
                  return (userPass == temp.userPass);
              }
              return false;
      }
      
          public UserClient(string fullNam, string aLevel, int usId, int pass)
      {
              fullName = fullNam;
              accLevel = aLevel;
              userId = usId;
              userPass = pass;
      }
      }
      

      }

      Could someone please help me crack this problem.... thanks in advance kind regards lapeci

      R Offline
      R Offline
      RobCroll
      wrote on last edited by
      #2

      lapeci, forum guidelines state "do not post the same question in more than one forum." see answer to question in C# forum.

      "You get that on the big jobs."

      1 Reply Last reply
      0
      • L LAPEC

        Hello Everyone I have created a Client/Server application on C# on WPF IDE and I have a little problem on my UserClient property class... Within this class I have a method called:

        public override bool Equals(object obj)
        {
        UserClient temp = obj as UserClient;
        if (temp != null)
        {
        return (userId == temp.userId);
        }
        if (temp != null)
        {
        return (userPass == temp.userPass);
        }
        return false;
        }

        The problem I'm having is: The class UserClient is highlighted with a green line under-neath where when I place MouseOver it sas: UserClient overrides Object.Equals but does not override Object.GetHashCode Here is the entire UserClient class code:

        using System;
        using System.Collections;
        using System.Collections.Generic;
        using System.Data;
        using System.Diagnostics;

        namespace DtposClient
        {
        public class UserClient
        {
        // User Client Global variables
        // ====================================
        private string UserFullName;
        private string UserAccessLevel;
        private int UserId;
        private int UserPassword;

        public string fullName
            {
                get { return UserFullName; }
                set { UserFullName = value; }
        }
        
            public string accLevel
            {
                get { return UserAccessLevel; }
                set { UserAccessLevel = value; }
            }
        
            public int userId
            {
                get { return UserId; }
                set { UserId = value; }
            }
            
        public int userPass 
            {
                get { return UserPassword; }
                set { UserPassword = value; }
            }
            
        public override bool Equals(object obj)
        {
                UserClient temp = obj as UserClient;
                if (temp != null)
                {
                    return (userId == temp.userId);
                }
                if (temp != null)
                {
                    return (userPass == temp.userPass);
                }
                return false;
        }
        
            public UserClient(string fullNam, string aLevel, int usId, int pass)
        {
                fullName = fullNam;
                accLevel = aLevel;
                userId = usId;
                userPass = pass;
        }
        }
        

        }

        Could someone please help me crack this problem.... thanks in advance kind regards lapeci

        P Offline
        P Offline
        Pete OHanlon
        wrote on last edited by
        #3

        That's easy. Whenever you override Equals, you are required to override GetHashCode. All you need to do is add an override for this method. The reason you need to do this is because you have changed the way equality works, so without a custom hashcode, you can end up with two different objects with the same hashcode - hence a problem with equality. BTW, you should have posted this in the C# forum as it's a generic C# problem. The fact that the application is WPF is neither here nor there.

        I'm not a stalker, I just know things. Oh by the way, you're out of milk.

        Forgive your enemies - it messes with their heads

        My blog | My articles | MoXAML PowerToys | Onyx

        1 Reply Last reply
        0
        • L LAPEC

          Hello Everyone I have created a Client/Server application on C# on WPF IDE and I have a little problem on my UserClient property class... Within this class I have a method called:

          public override bool Equals(object obj)
          {
          UserClient temp = obj as UserClient;
          if (temp != null)
          {
          return (userId == temp.userId);
          }
          if (temp != null)
          {
          return (userPass == temp.userPass);
          }
          return false;
          }

          The problem I'm having is: The class UserClient is highlighted with a green line under-neath where when I place MouseOver it sas: UserClient overrides Object.Equals but does not override Object.GetHashCode Here is the entire UserClient class code:

          using System;
          using System.Collections;
          using System.Collections.Generic;
          using System.Data;
          using System.Diagnostics;

          namespace DtposClient
          {
          public class UserClient
          {
          // User Client Global variables
          // ====================================
          private string UserFullName;
          private string UserAccessLevel;
          private int UserId;
          private int UserPassword;

          public string fullName
              {
                  get { return UserFullName; }
                  set { UserFullName = value; }
          }
          
              public string accLevel
              {
                  get { return UserAccessLevel; }
                  set { UserAccessLevel = value; }
              }
          
              public int userId
              {
                  get { return UserId; }
                  set { UserId = value; }
              }
              
          public int userPass 
              {
                  get { return UserPassword; }
                  set { UserPassword = value; }
              }
              
          public override bool Equals(object obj)
          {
                  UserClient temp = obj as UserClient;
                  if (temp != null)
                  {
                      return (userId == temp.userId);
                  }
                  if (temp != null)
                  {
                      return (userPass == temp.userPass);
                  }
                  return false;
          }
          
              public UserClient(string fullNam, string aLevel, int usId, int pass)
          {
                  fullName = fullNam;
                  accLevel = aLevel;
                  userId = usId;
                  userPass = pass;
          }
          }
          

          }

          Could someone please help me crack this problem.... thanks in advance kind regards lapeci

          A Offline
          A Offline
          Abhinav S
          wrote on last edited by
          #4

          You can always use the new method to create a method of your own (breaking away from the inheritance hierarchy).

          The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it. My latest tip/trick

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups