Ejemplo n.º 1
0
        public override bool Equals(Object obj)
        {
            // Check for null values and compare run-time types.
            if (obj == null)
            {
                return(false);
            }
            if (!(obj is String8bit))
            {
                return(false);
            }
            String8bit comp = (String8bit)obj;

            if (comp.Bytes.Length != this.Bytes.Length)
            {
                return(false);
            }
            for (Int32 i = 0; i < comp.Bytes.Length; i++)
            {
                if (comp.Bytes[i] != this.Bytes[i])
                {
                    return(false);
                }
            }
            return(true);
        }
Ejemplo n.º 2
0
        public MainWindow()
        {
            InitializeComponent();
            String8bit           s1 = new String8bit("cat");
            String8bit           s2 = new String8bit("cat");
            String8bit           s3 = new String8bit("dog");
            HashSet <String8bit> hs = new HashSet <String8bit>();

            hs.Add(s1);
            hs.Add(s2);
            hs.Add(s3);
            System.Diagnostics.Debug.WriteLine(hs.Count.ToString());
            System.Diagnostics.Debug.WriteLine(s1.Value + " " + s1.GetHashCode().ToString());
            System.Diagnostics.Debug.WriteLine(s1.Value + " " + s1.GetHashCode().ToString());
            System.Diagnostics.Debug.WriteLine(s1.Value + " " + s1.GetHashCode().ToString());
            System.Diagnostics.Debug.WriteLine(s1.Equals(s2).ToString());
            System.Diagnostics.Debug.WriteLine(s1.Equals(s3).ToString());
        }
Ejemplo n.º 3
0
        public MainWindow()
        {
            InitializeComponent();
            String8bit           s1 = new String8bit("cat");
            String8bit           s2 = new String8bit("cat");
            String8bit           s3 = new String8bit("\xFD\x0B\x16MBEPEXE1.");
            HashSet <String8bit> hs = new HashSet <String8bit>();

            hs.Add(s1);
            hs.Add(s2);
            hs.Add(s3);
            System.Diagnostics.Debug.WriteLine(hs.Count.ToString());
            System.Diagnostics.Debug.WriteLine(s1.Value + " " + s1.GetHashCode().ToString());
            System.Diagnostics.Debug.WriteLine(s2.Value + " " + s2.GetHashCode().ToString());
            System.Diagnostics.Debug.WriteLine(s3.Value + " " + s3.GetHashCode().ToString());
            System.Diagnostics.Debug.WriteLine(s1.Equals(s2).ToString());
            System.Diagnostics.Debug.WriteLine(s1.Equals(s3).ToString());
            System.Diagnostics.Debug.WriteLine(s1.MatchStart("ca").ToString());
            System.Diagnostics.Debug.WriteLine(s3.MatchStart("ca").ToString());
        }