コード例 #1
0
        static void Main(string[] args)
        {
            Console.WriteLine($"Press 'a' or 'b'. Everything else finishes the program.");

            ConsoleKeyInfo info = Console.ReadKey();

            while (true)
            {
                if (info.KeyChar != 'a' && info.KeyChar != 'b')
                {
                    Console.WriteLine($"");
                    Console.WriteLine($"You typed {info.Key} so the program is finished.");
                    Console.WriteLine($"The hash code is {info.GetHashCode()}");
                    break;
                }
                else
                {
                    Console.WriteLine($"");
                    Console.WriteLine($"You typed {info.Key}.");
                    Console.WriteLine($"The hash code is {info.GetHashCode()}");
                }

                info = Console.ReadKey();
            }
        }
コード例 #2
0
        public void Equals_SameData(ConsoleKeyInfo cki)
        {
            ConsoleKeyInfo other = cki; // otherwise compiler warns about comparing the instance with itself

            Assert.True(cki.Equals((object)other));
            Assert.True(cki.Equals(other));
            Assert.True(cki == other);
            Assert.False(cki != other);

            Assert.Equal(cki.GetHashCode(), other.GetHashCode());
        }
コード例 #3
0
        public void Equals_SameData(ConsoleKeyInfo cki)
        {
            ConsoleKeyInfo other = cki; // otherwise compiler warns about comparing the instance with itself

            Assert.True(cki.Equals((object)other));
            Assert.True(cki.Equals(other));
            Assert.True(cki == other);
            Assert.False(cki != other);

            Assert.Equal(cki.GetHashCode(), other.GetHashCode());
        }
コード例 #4
0
        }     //end of the function

        public void GeneratePageView(List <string> data)
        {
            Console.Clear();
            int currentPageIndex = 0;
            int total            = data.Count;

            while (true)
            {
                Console.WriteLine(
                    $"---------------------------- Đang hiển thị trang {currentPageIndex + 1} trên tổng số {total} trang ----------------------------");
                Console.WriteLine(data[currentPageIndex]);
                Console.WriteLine(
                    "--------------------------------------------------------------------------------------------------------------------------------");
                Console.WriteLine("ấn > để next, ấn < để back, ấn esc để exit");
                ConsoleKeyInfo keyInfo = Console.ReadKey(true);
                int            charKey = keyInfo.GetHashCode(); //get ascii code of keyboard character entered
                if (charKey == 46)                              // 62 is ascii code of '.' or >
                {
                    Console.Clear();
                    currentPageIndex++;
                    if (currentPageIndex > total - 1)
                    {
                        currentPageIndex = 0;
                        continue;
                    }
                }

                if (charKey == 44) //60 is ascii code of comma ',' or <
                {
                    Console.Clear();
                    currentPageIndex--;
                    if (currentPageIndex < 0)
                    {
                        currentPageIndex = total - 1;
                        continue;
                    }
                }

                if (charKey == 27) //27 is ascii code of esc
                {
                    break;
                }
            }
        }
コード例 #5
0
 public void HashCodeNotEquals_DifferentData(ConsoleKeyInfo left, ConsoleKeyInfo right)
 {
     Assert.NotEqual(left.GetHashCode(), right.GetHashCode());
 }
コード例 #6
0
 public void HashCodeNotEquals_DifferentData(ConsoleKeyInfo left, ConsoleKeyInfo right)
 {
     Assert.NotEqual(left.GetHashCode(), right.GetHashCode());
 }