Ex1: class RefOutOverloadExample { public void SampleMethod(int i) { }

Slides:



Advertisements
Similar presentations
For(int i = 1; i
Advertisements

C# Language Report By Trevor Adams. Language History Developed by Microsoft Developed by Microsoft Principal Software Architect Principal Software Architect.
Tinaliah, S. Kom.. * * * * * * * * * * * * * * * * * #include using namespace std; void main () { for (int i = 1; i
Triana Elizabeth, S.Kom. #include using namespace std; void main () { for (int i = 1; i
Arrays Session 05 Mata kuliah: M0874 – Programming II Tahun: 2010.
Passing information through Parameters ( our setter methods or mutators) Formal Parameter – parameter in the method. public void SetA(int x){ (int x) is.
03/16/ What is an Array?... An array is an object that stores list of items. Each slot of an array holds an individual element. Characteristics.
Overview of C# CS331. Structure of a C# Program // Specify namespaces we use classes from here using System; using System.Threading; // Specify more specific.
CIS 3301 C# Lesson 5 Methods. CIS 3302 Objectives Understand the structure of a method. Know the difference between static and instance methods. Learn.
Hoang Anh Viet Hà Nội University of Technology Chapter 1. Introduction to C# Programming.
Methods SWE 344 Internet Protocols & Client Server Programming.
BİL527 – Bilgisayar Programlama I Functions 1. Contents Functions Delegates 2.
Introduction to C# By: Abir Ghattas Michel Barakat.
Enum,Structure and Nullable Types Ashima Wadhwa. Enumerations, Enumerations, or enums, are used to group named constants similar to how they are used.
New Java Features Advanced Programming Techniques.
Request Dispatching for Cheap Energy Prices in Cloud Data Centers
Choosing a Dental Plan Student Name
Virtual Environments and Computer Graphics
Chương 1: CÁC PHƯƠNG THỨC GIAO DỊCH TRÊN THỊ TRƯỜNG THẾ GIỚI
D. Phát triển thương hiệu
Điều trị chống huyết khối trong tai biến mạch máu não
INTRODUCTION BEGINNING C#. C# AND THE.NET RUNTIME AND LIBRARIES The C# compiler compiles and convert C# programs. NET Common Language Runtime (CLR) executes.
Electronics for Pedestrians – Passive Components –
L-Systems and Affine Transformations
Current State of Japanese Economy under Negative Interest Rate and Proposed Remedies Naoyuki Yoshino Dean Asian Development Bank Institute Professor Emeritus,
Face Recognition Monday, February 1, 2016.
انتقال حرارت 2 خانم خسرویار.
Creating Synthetic Microdata for Higher Educational Use in Japan: Reproduction of Distribution Type based on the Descriptive Statistics Kiyomi Shirakawa.
Fuel cell development program for electric vehicle
Overview of TST-2 Experiment
Optomechanics with atoms
Inter-system biases estimation in multi-GNSS relative positioning with GPS and Galileo Cecile Deprez and Rene Warnant University of Liege, Belgium  
Interpretations of the Derivative Gottfried Wilhelm Leibniz
Widow Rockfish Assessment
SiW-ECAL Beam Test 2015 Kick-Off meeting
You NEED your book!!! Frequency Distribution
Methods Matthew Harrison. Overview ● There are five main aspects of methods... ● 1) Modifiers – public, private ● 2) Method Name ● 3) Parameters ● 4)
The ABCD matrix for parabolic reflectors and its application to astigmatism free four-mirror cavities.
Intro to C# for Java people
Quantum-classical transition in optical twin beams and experimental applications to quantum metrology Ivano Ruo-Berchera Frascati.
NV centers in diamond: from quantum coherence to nanoscale MRI
Mitchell Cox University of the Witwatersrand, Johannesburg
C3q Measurement Using Polarized e+/e- Beams at JLab
Solar Astronomy with LOFAR - First Steps
Free Cooling Application for Energy Savings at Purdue
Calibration: more background
C# for C++ Programmers 1.
Agenda Array accessing Automatic initialization of an array
התוכנית: using System; using System.Collections.Generic;
BİL527 – Bilgisayar Programlama I
Parameter Passing & Array Examples – Part 1
Inheritance & Polymorphism
Advanced Programming Chapter 8: Arrays
Lecture 3 Functions Simple functions
Pointers & Functions.
محاور المحاضرة خوارزمية الفقاعات الهوائية (Bubble Sort)
CIS 199 Test 02 Review.
Arrays.
class PrintOnetoTen { public static void main(String args[]) {
1D Arrays and Lots of Brackets
Module 2 Variables, Assignment, and Data Types
Methods and Data Passing
Class.
The Lifecycle of an Object
When an argument to method is an entire array or an individual element of reference type, the called method receives a copy of reference. However an argument.
Stacks.
Introduction to C#.net PROF. S. LAKSHMANAN,
Pointers & Functions.
Ps Module 7 – Part II 2D Arrays and LISTS 5/26/2019 CSE 1321 Module 7.
Interfaces, Enumerations, Boxing, and Unboxing
Presentation transcript:

Ex1: class RefOutOverloadExample { public void SampleMethod(int i) { } public void SampleMethod(ref int i) { } } Ex2: class RefOutOverloadExample { public void SampleMethod(int i) { } public void SampleMethod(out int i) { } }

Passing Arrays Using ref and out void TestMethod1(out int[] arr) { arr = new int[10]; } void TestMethod2(ref int[] arr) { arr = new int[10]; }

class TestOut { void FillArray(out int[] arr) // Initialize the array: arr = new int[5] { 1, 2, 3, 4, 5 }; } static void Main() { TestOut ob=new TestOut(); int[] theArray; // Initialization is not required ob. FillArray(out theArray); // Pass the array to the callee using out: // Display the array elements: System.Console.WriteLine("Array elements are:"); for (int i = 0; i < theArray.Length; i++) System.Console.Write(theArray[i] + " ");

The params Keyword using System; namespace UsingParams { public class Tester public void DisplayVals(params int[] y) foreach (int i in y) Console.WriteLine("The Value {0}",i); } static void Main( ) Tester t = new Tester( ); t.DisplayVals(5,6,7,8); int [] x = new int[5] {1,2,3,4,5}; t.DisplayVals(x);

Object using System; namespace boxing { public class UnboxingTest { public static void Main( ) { int i = 123; object o = i; //Boxing int j = ( int ) o; // unboxing (must be explicit) Console.WriteLine( "j: {0}", j ); }

using System; class xxx { public int i = 10; } class MainClass static void Main() object a; a = 1; // an example of boxing Console.WriteLine(a); a = new xxx(); xxx b; b = (xxx)a; Console.WriteLine(b.i);

public class MyClass { public void UseParams(params int[] list) for (int i = 0 ; i < list.Length; i++) Console.WriteLine(list[i]); } Console.WriteLine(); public void UseParams2(params object[] list) static void Main() MyClass ob= new MyClass(); ob.UseParams(1, 2, 3); ob.UseParams2(1, 'a', "test"); int[] myarray = new int[3] {10,11,12}; ob.UseParams(myarray); }}

Enumerations <modifier> enum <enumeration name> { - - - - - - - - - - - - - - - };