コード例 #1
0
ファイル: Form1.cs プロジェクト: gabrijela28/PI2
        private void button1_Click(object sender, EventArgs e)
        {
            float MyFloat;

            MyFloat = 0.42F;
            MessageBox.Show(MyFloat.ToString());
        }
コード例 #2
0
 public static float64 Abs(this MyFloat f)
 {
     if (f < 0)
     {
         return(float64(-f));
     }
     return(float64(f));
 }
コード例 #3
0
 /// <summary>
 /// Returns the hashcode of this Object
 /// </summary>
 /// <returns>Hash code (int)</returns>
 public override int GetHashCode()
 {
     // Credit: http://stackoverflow.com/a/263416/677735
     unchecked             // Overflow is fine, just wrap
     {
         int hash = 41;
         // Suitable nullity checks etc, of course :)
         if (Id != null)
         {
             hash = hash * 59 + Id.GetHashCode();
         }
         if (Name != null)
         {
             hash = hash * 59 + Name.GetHashCode();
         }
         if (Description != null)
         {
             hash = hash * 59 + Description.GetHashCode();
         }
         if (MyBoolean != null)
         {
             hash = hash * 59 + MyBoolean.GetHashCode();
         }
         if (MyCreditCard != null)
         {
             hash = hash * 59 + MyCreditCard.GetHashCode();
         }
         if (MyCurrency != null)
         {
             hash = hash * 59 + MyCurrency.GetHashCode();
         }
         if (MyDateTime != null)
         {
             hash = hash * 59 + MyDateTime.GetHashCode();
         }
         if (MyDouble != null)
         {
             hash = hash * 59 + MyDouble.GetHashCode();
         }
         if (MyEmail != null)
         {
             hash = hash * 59 + MyEmail.GetHashCode();
         }
         if (MyFloat != null)
         {
             hash = hash * 59 + MyFloat.GetHashCode();
         }
         if (MyImageUrl != null)
         {
             hash = hash * 59 + MyImageUrl.GetHashCode();
         }
         if (MyInteger != null)
         {
             hash = hash * 59 + MyInteger.GetHashCode();
         }
         if (MyLong != null)
         {
             hash = hash * 59 + MyLong.GetHashCode();
         }
         if (MyPhone != null)
         {
             hash = hash * 59 + MyPhone.GetHashCode();
         }
         if (MyPostalCode != null)
         {
             hash = hash * 59 + MyPostalCode.GetHashCode();
         }
         if (MyString != null)
         {
             hash = hash * 59 + MyString.GetHashCode();
         }
         if (MyTextArea != null)
         {
             hash = hash * 59 + MyTextArea.GetHashCode();
         }
         if (MyTicks != null)
         {
             hash = hash * 59 + MyTicks.GetHashCode();
         }
         if (MyUrl != null)
         {
             hash = hash * 59 + MyUrl.GetHashCode();
         }
         if (Comments != null)
         {
             hash = hash * 59 + Comments.GetHashCode();
         }
         if (AuditEntered != null)
         {
             hash = hash * 59 + AuditEntered.GetHashCode();
         }
         if (AuditEnteredBy != null)
         {
             hash = hash * 59 + AuditEnteredBy.GetHashCode();
         }
         if (AuditUpdated != null)
         {
             hash = hash * 59 + AuditUpdated.GetHashCode();
         }
         if (AuditUpdatedBy != null)
         {
             hash = hash * 59 + AuditUpdatedBy.GetHashCode();
         }
         return(hash);
     }
 }
コード例 #4
0
ファイル: Program.cs プロジェクト: 0916174/INFDEV
        private static void Main(string[] args)
        {
            #region Exercise 1

            Console.WriteLine("Exercise1");

            INumberVisitor Vis = new NumberVisitor();
            INumber Barry = new MyFloat(2);
            INumber Henk = new MyFloat(3);

            Barry.Visit(Vis);
            Console.WriteLine("");

            #endregion Exercise 1

            #region Exercise 2

            Console.WriteLine("Exercise2");

            IMusicLibraryVisitor MusicLibraryVisitor = new MusicLibraryVisitor();

            ISong HMSong1 = new HeavyMetal("Super Kill");
            ISong JSong1 = new Jazz("Frank Sinatra: The Very Best Of");

            List<ISong> SongList = new List<ISong>();
            SongList.Add(HMSong1);
            SongList.Add(JSong1);

            foreach (ISong Song in SongList)
            {
                Song.Visit(MusicLibraryVisitor);
            }

            Console.WriteLine("");

            #endregion Exercise 2

            #region Exercise 3

            Console.WriteLine("Exercise3");

            IOption<int> TestInt1 = new Some<int>(5);
            IOption<int> TestInt2 = new None<int>();
            I_IntPrettyPrinterIOptionVisitor IntPrint = new IntPrettyPrinterIOptionVisitor();

            string TestString1 = TestInt1.Visit(IntPrint);
            Console.WriteLine(TestString1);

            Console.WriteLine("");

            #endregion Exercise 3

            #region Exercise 4

            Console.WriteLine("Exercise4");

            IOptionLambda<MyFloat> f1 = new NoneLambda<MyFloat>();
            string new_number1 = f1.Visit(x => x.value.ToString(), () => "Nothing here, b0ss.");
            Console.WriteLine(new_number1);

            IOptionLambda<MyFloat> f2 = new SomeLambda<MyFloat>(new MyFloat(5));
            string new_number2 = f2.Visit(x => "The number is " + x.value.ToString() + "! :D", () => "Nothing here, b0ss.");
            Console.WriteLine(new_number2);

            #endregion Exercise 4

            Console.ReadKey();
        }
コード例 #5
0
 public static double Abs(this MyFloat f)
 {
     iff < 0 { returnfloat64(-f) } returnfloat64(f)
 }
コード例 #6
0
 public void onMyFloat(MyFloat MyFloat)
 {
     Console.WriteLine("Found float!");
 }
コード例 #7
0
 public Task <float> SubFloatTask(MyFloat data)
 {
     return(Task.FromResult(data.Data));
 }
コード例 #8
0
ファイル: NumberVisitor.cs プロジェクト: 0916174/INFDEV
 public float onMyFloat(MyFloat Float)
 {
     Console.WriteLine("Found float");
     return Float.value;
 }