This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void PrintAgeAsInt(object age) | |
{ | |
if (age is int intAge || (age is string stringAge && int.TryParse(stringAge, out intAge))) | |
{ | |
Console.WriteLine($"Age is {intAge}"); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Dog MarlieTheDog = new Dog(name: "Marlie", age: 7, isFriendly: false); | |
Cat GarfieldTheCat = new Cat(name: "Garfield", age: 10, isMean: false); | |
Animal goodAnimal = MarlieTheDog; | |
switch (goodAnimal) | |
{ | |
case Dog d when d.IsFriendly: | |
Console.WriteLine(d.Age); | |
break; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Dog marlieTheDog = new Dog(name: "Marlie", age: 7, isFriendly: false); | |
Cat garfieldTheCat = new Cat(name: "Garfield", age: 10, isMean: false); | |
Animal goodAnimal = marlieTheDog; | |
switch (goodAnimal) | |
{ | |
case Dog d when d.IsFriendly: //הצהרה על כלב חדש וביצוע תשאול על מאפייניו | |
Console.WriteLine(d.Age); //כאן בהכרח יודפס גיל של כלב ידידותי | |
break; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Dog marlieTheDog = new Dog(name: "Marlie", age: 7, isFriendly: false); // Animal יורש מ | |
Cat garfieldTheCat = new Cat(name: "Garfield", age: 7, isMean: false); // Animal יורש מ | |
List<Animal> animals = new List<Animal>() { marlieTheDog, garfieldTheCat }; //יצירת רשימה המכילה חתול וכלב | |
Animal oldAnimal = animals.Where(animal => animal.Age > 8).FirstOrDefault(); //הצהרה על חיה חדשה - החיה הראשונה ברשימה שגילה גדול מ-8 | |
if (oldAnimal == null) //בדיקה התבצעה השמה לחיה מבוגרת | |
{ | |
throw new Exception("There aren't any old animals in here"); //Exception במקרה ולא קיימת חיה מבוגרת ברשימה - זריקת | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Dog marlieTheDog = new Dog(name: "Marlie", age: 7, isFriendly: false); | |
Cat garfieldTheCat = new Cat(name: "Garfield", age: 7, isMean: false); | |
List<Animal> animals = new List<Animal>() { marlieTheDog, garfieldTheCat }; | |
Animal oldAnimal = animals.Where(animal => animal.Age > 8).FirstOrDefault() ?? throw new Exception("There aren't any old animals in here"); | |
// אם לא הוכנס ערך, תזרק שגיאה מתאימה | |
Console.WriteLine($"{oldAnimal.Name} is very old"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static (string name, int age) GetNameAndAge() | |
{ | |
string myName = "Tomer"; | |
int myAge = 22; | |
return (myName, myAge); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static double AverageThreeNumbers(int num1, int num2, int num3) | |
{ | |
int Sum(int numOne, int numTwo, int numThree) //יצירת פעולה פנימית שמחזירה סכום של שלושה מספרים | |
{ | |
return numOne + numTwo + numThree; | |
} | |
double Division(int numUno, int numDos) //יציאת פעולה פנימית שמחזירה את מנתם של שני מספרים | |
{ | |
return numUno / numDos; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Dog : Animal | |
{ | |
private bool isFriendly; | |
public bool IsFriendly | |
{ | |
get => this.isFriendly; | |
set => this.isFriendly = value; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using NUnit.Framework; | |
using OpenQA.Selenium; | |
using OpenQA.Selenium.Chrome; | |
using OpenQA.Selenium.Support.UI; | |
using System; | |
namespace FirstSelenium | |
{ | |
[TestFixture] | |
public class FirstSelenium |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void DoubleTheNumber(int num) | |
{ | |
Console.WriteLine(num * 2); | |
} |
OlderNewer