using System.IO; using System; class Program { static void Main() { /*int [] numbers = new int [5]; // numbers [0] = 4; //numbers [1] = 8; //numbers [2] = 15; //numbers [3] = 16; numbers [4] = 23; //Console.WriteLine(numbers[1]); Console.WriteLine(numbers.Length); Console.ReadLine(); int [] numbers = new int []{4, 8, 15, 16, 23, 42};*/ string[] names = new string [] {"Eddie", "Alex", "Micheal", "David Lee"}; /* for (int i =0; i < names.Length; i++) { Console.WriteLine(names[i]); } Console.ReadLine();*/ foreach ( string name in names) { Console.WriteLine(name); } Console.ReadLine(); } }
using static System.Console; public class Program { public static void Main() { var x = 1; WriteLine(x == 1 || x == 2); WriteLine(x == 1 || x != 2); WriteLine(x != 1 || x != 2); WriteLine(x == 1 && x == 2); WriteLine(x == 1 && x != 2); WriteLine(x != 1 && x != 2); WriteLine(x == 3 || x == 2); WriteLine(x == 3 || x != 2); WriteLine(x != 3 || x != 1); WriteLine(x == 3 && x == 2); WriteLine(x == 3 && x != 2); WriteLine(x != 3 && x != 2); } } //https://pt.stackoverflow.com/q/46086/101
using System.IO; using System; class Program { int[] factors; int[] count; int[][] jagg; static void Main() { Program pg = new Program(); pg.factors = new int[3] {100, 200, 300}; pg.count = new int[3] {3, 4, 5}; pg.MakeJaggedArray(pg.factors, pg.count); pg.ShowJaggedArray(pg.jagg); Console.WriteLine(); pg.ShowJaggedSingle(pg.jagg, 0); } void MakeJaggedArray(int[] myfactors, int[] mycount) { jagg = new int[myfactors.Length][]; for(int i=0; i < myfactors.Length; i++) { jagg[i] = new int[mycount[i]]; for(int j=0; j< mycount[i]; j++) { jagg[i][j] = myfactors[i] + 3 * j; } } } void ShowJaggedArray(int[][] myJagg) { for(int i=0; i < myJagg.Length; i++) { for(int j=0; j< myJagg[i].Length; j++) { Console.Write("jagg[{0}][{1}] : ",i,j); Console.WriteLine(myJagg[i][j]); } } } void ShowJaggedSingle(int[][] myJagg, int index) { for(int i=0; i < myJagg.Length; i++) { Console.Write("jagg[{0}][",i); for(int j=0; j< myJagg[i].Length; j++) { Console.Write(myJagg[i][j] + "\t"); } Console.WriteLine("\b]"); } } }
using System.IO; using System; class Program { static void Main() { int s=21,user,computer,n=0; while(s>=1) { if(s==1) { Console.WriteLine("computer won the game"); break; } user= Convert.ToInt32(Console.ReadLine()); if(user>4) { Console.WriteLine("invalid"); } else { Console.WriteLine("user's turn= "+user); computer=5-user; Console.WriteLine("computer's turn= "+computer); n+=(user+computer); } s=21-n; } } }
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement; public class LoadScene : MonoBehaviour { public void loadScenePerID(int sceneID) { SceneManager.LoadScene(sceneID); } public void loadScenePerName(string sceneName) { SceneManager.LoadScene(sceneName); } public void quitGame() { Application.Quit(); } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp1 { class mono { static void Main(string[] args) { console.WriteLine("hellovmart "); Console.ReadKey(); } } }
using System; namespace PolymorphismApplication { abstract class Shape { public abstract int area(); } class Rectangle: Shape { private int length; private int width; public Rectangle( int a = 0, int b = 0) { length = a; width = b; } public override int area () { Console.WriteLine("Rectangle class area :"); return (width * length); } } class RectangleTester { static void Main(string[] args) { Rectangle r = new Rectangle(10, 7); double a = r.area(); Console.WriteLine("Area: {0}",a); Console.ReadKey(); } } }
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy. Accept Learn more