0% found this document useful (0 votes)
4 views

C# Unit 5

The document covers key concepts of C# including Generics, Delegates, Reflection, and Multithreading. It explains how to define generic classes and methods, the use of delegates for method references, and the process of obtaining type metadata at runtime through reflection. Additionally, it describes the multithreading capabilities in C#, detailing thread lifecycle, properties, methods, and examples of creating and managing threads.

Uploaded by

Ritu Sonwane
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

C# Unit 5

The document covers key concepts of C# including Generics, Delegates, Reflection, and Multithreading. It explains how to define generic classes and methods, the use of delegates for method references, and the process of obtaining type metadata at runtime through reflection. Additionally, it describes the multithreading capabilities in C#, detailing thread lifecycle, properties, methods, and examples of creating and managing threads.

Uploaded by

Ritu Sonwane
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 34

UNIT – V

C# Generics
Generic is a concept that allows us to define classes and methods with placeholder. C# compiler
replaces these placeholders with specified type at compile time. The concept of generics is used
to create general purpose classes and methods.
o define generic class, we must use angle <> brackets. The angle brackets are used to declare a
class or method as generic type. In the following example, we are creating generic class that can
be used to deal with any type of data.

Example
using System;
namespace CSharpProgram
{
class GenericClass<T>
{
public GenericClass(T msg)
{
Console.WriteLine(msg);
}
}
class Program
{
static void Main(string[] args)
{
GenericClass<string> gen = new GenericClass<string> ("This is generic class");
GenericClass<int> genI = new GenericClass<int>(101);
GenericClass<char> getCh = new GenericClass<char>('I');
}
}
}

Output:

This is generic class


101
I

C# allows us to create generic methods also. In the following example, we are creating generic
method that can be called by passing any type of argument.

Generic Method Example


using System;
namespace CSharpProgram
{
class GenericClass
{
public void Show<T>(T msg)
{
Console.WriteLine(msg);
}
}
class Program
{
static void Main(string[] args)
{
GenericClass genC = new GenericClass();
genC.Show("This is generic method");
genC.Show(101);
genC.Show('I');
}
}
}

Output:

This is generic method


101
I

C# Delegates

In C#, delegate is a reference to the method. It works like function pointer in C and C++. But it is
objected-oriented, secured and type-safe than function pointer.

For static method, delegate encapsulates method only. But for instance method, it encapsulates
method and instance both.

The best use of delegate is to use as event.

Internally a delegate declaration defines a class which is the derived class of System.Delegate.

Example
Let's see a simple example of delegate in C# which calls add() and mul() methods.

using System;
delegate int Calculator(int n);//declaring delegate

public class DelegateExample


{
static int number = 100;
public static int add(int n)
{
number = number + n;
return number;
}
public static int mul(int n)
{
number = number * n;
return number;
}
public static int getNumber()
{
return number;
}
public static void Main(string[] args)
{
Calculator c1 = new Calculator(add);//instantiating delegate
Calculator c2 = new Calculator(mul);
c1(20);//calling method using delegate
Console.WriteLine("After c1 delegate, Number is: " + getNumber());
c2(3);
Console.WriteLine("After c2 delegate, Number is: " + getNumber());

}
}
Output:
After c1 delegate, Number is: 120
After c2 delegate, Number is: 360

C# Reflection

In C#, reflection is a process to get metadata of a type at runtime. The System.Reflection


namespace contains required classes for reflection such as:
 Type
 MemberInfo
 ConstructorInfo
 MethodInfo
 FieldInfo
 PropertyInfo
 TypeInfo
 EventInfo
 Module
 Assembly
 AssemblyName
 Pointer etc.

The System.Reflection.Emit namespace contains classes to emit metadata.

C# Type class

C# Type class represents type declarations for class types, interface types, enumeration types,
array types, value types etc. It is found in System namespace. It inherits
System.Reflection.MemberInfo class.

C# Type Properties

A list of important properties of Type class are given below:

Property Description

Assembly Gets the Assembly for this type.

AssemblyQualifiedName Gets the Assembly qualified name for this type.

Attributes Gets the Attributes associated with the type.

BaseType Gets the base or parent type.


FullName Gets the fully qualified name of the type.

IsAbstract is used to check if the type is Abstract.

IsArray is used to check if the type is Array.

IsClass is used to check if the type is Class.

IsEnum is used to check if the type is Enum.

IsInterface is used to check if the type is Interface.

IsNested is used to check if the type is Nested.

IsPrimitive is used to check if the type is Primitive.

IsPointer is used to check if the type is Pointer.

IsNotPublic is used to check if the type is not Public.

IsPublic is used to check if the type is Public.

IsSealed is used to check if the type is Sealed.

IsSerializable is used to check if the type is Serializable.

MemberType is used to check if the type is Member type of Nested type.

Module Gets the module of the type.

Name Gets the name of the type.

Namespace Gets the namespace of the type.

C# Type Methods
A list of important methods of Type class are given below:

Method Description
GetConstructors() Returns all the public constructors for the Type.

GetConstructors(BindingFlags) Returns all the constructors for the Type with specified
BindingFlags.

GetFields() Returns all the public fields for the Type.

GetFields(BindingFlags) Returns all the public constructors for the Type with specified
BindingFlags.

GetMembers() Returns all the public members for the Type.

GetMembers(BindingFlags) Returns all the members for the Type with specified BindingFlags.

GetMethods() Returns all the public methods for the Type.

GetMethods(BindingFlags) Returns all the methods for the Type with specified BindingFlags.

GetProperties() Returns all the public properties for the Type.

GetProperties(BindingFlags) Returns all the properties for the Type with specified BindingFlags.

GetType() Gets the current Type.

GetType(String) Gets the Type for the given name.

C# Reflection Example: Get Type


using System;
public class ReflectionExample
{
public static void Main()
{
int a = 10;
Type type = a.GetType();
Console.WriteLine(type);
}
}

Output:

System.Int32

C# Reflection Example: Get Assembly


using System;
using System.Reflection;
public class ReflectionExample
{
public static void Main()
{
Type t = typeof(System.String);
Console.WriteLine(t.Assembly);
}
}

Output:

mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

C# Reflection Example: Print Type Information


using System;
using System.Reflection;
public class ReflectionExample
{
public static void Main()
{
Type t = typeof(System.String);
Console.WriteLine(t.FullName);
Console.WriteLine(t.BaseType);
Console.WriteLine(t.IsClass);
Console.WriteLine(t.IsEnum);
Console.WriteLine(t.IsInterface);
}
}

Output:

System.String
System.Object
true
false
false

C# Reflection Example: Print Constructors


using System;
using System.Reflection;
public class ReflectionExample
{
public static void Main()
{
Type t = typeof(System.String);

Console.WriteLine("Constructors of {0} type...", t);


ConstructorInfo[] ci = t.GetConstructors(BindingFlags.Public | BindingFlags.Instance);
foreach (ConstructorInfo c in ci)
{
Console.WriteLine(c);
}
}
}

Output:

Constructors of System.String type...


Void .ctor(Char*)
Void .ctor(Char*, Int32, Int32)
Void .ctor(SByte*)
Void .ctor(SByte*, Int32, Int32)
Void .ctor(SByte*, Int32, Int32, System.Text.Encoding)
Void .ctor(Char[], Int32, Int32)
Void .ctor(Char[])
Void .ctor(Char, Int32)

C# Reflection Example: Print Methods


using System;
using System.Reflection;
public class ReflectionExample
{
public static void Main()
{
Type t = typeof(System.String);
Console.WriteLine("Methods of {0} type...", t);
MethodInfo[] ci = t.GetMethods(BindingFlags.Public | BindingFlags.Instance);
foreach (MethodInfo m in ci)
{
Console.WriteLine(m);
}
}
}

Output:

Methods of System.String type...


Boolean Equals(System.Object)
Boolean Equals(System.String)
Boolean Equals(System.String, System.StringComparison)
Char get_Chars(Int32)
Void copyTo(Int32, char[], Int32, Int32)
Char[] ToCharArray()
....

C# Reflection Example: Print Fields


using System;
using System.Reflection;
public class ReflectionExample
{
public static void Main()
{
Type t = typeof(System.String);

Console.WriteLine("Fields of {0} type...", t);


FieldInfo[] ci = t.GetFields(BindingFlags.Public | BindingFlags.Static | BindingFlags.NonP
ublic);
foreach (FieldInfo f in ci)
{
Console.WriteLine(f);
}
}
}

Output:

Fields of System.String type...


System.String Empty
Int32 TrimHead
Int32 TrimTail
Int32 TrimBoth
Int32 charPtrAlignConst
Int32 alignConst

C# Multithreading

Multithreading in C# is a process in which multiple threads work simultaneously. It is a process


to achieve multitasking. It saves time because multiple tasks are being executed at a time. To
create multithreaded application in C#, we need to use System.Threding namespace.

System.Threading Namespace
The System.Threading namespace contains classes and interfaces to provide the facility of
multithreaded programming. It also provides classes to synchronize the thread resource. A list of
commonly used classes are given below:

 Thread
 Mutex
 Timer
 Monitor
 Semaphore
 ThreadLocal
 ThreadPool
 Volatile etc.
Process and Thread
A process represents an application whereas a thread represents a module of the application.
Process is heavyweight component whereas thread is lightweight. A thread can be termed as
lightweight subprocess because it is executed inside a process.
Whenever you create a process, a separate memory area is occupied. But threads share a
common memory area.

C# Thread Life Cycle


In C#, each thread has a life cycle. The life cycle of a thread is started when instance
of System.Threading.Thread class is created. When the task execution of the thread is completed,
its life cycle is ended.
There are following states in the life cycle of a Thread in C#.

 Unstarted
 Runnable (Ready to run)
 Running
 Not Runnable
 Dead (Terminated)

Unstarted State
When the instance of Thread class is created, it is in unstarted state by default.

Runnable State
When start() method on the thread is called, it is in runnable or ready to run state.
Running State
Only one thread within a process can be executed at a time. At the time of execution, thread is in
running state.

Not Runnable State


The thread is in not runnable state, if sleep() or wait() method is called on the thread, or
input/output operation is blocked.

Dead State
After completing the task, thread enters into dead or terminated state.
C# Thread class
C# Thread class provides properties and methods to create and control threads. It is found in
System.Threading namespace.
C# Thread Properties
A list of important properties of Thread class are given below:

Property Description

CurrentThread returns the instance of currently running thread.

IsAlive checks whether the current thread is alive or not. It is used to find the execution
status of the thread.

IsBackground is used to get or set value whether current thread is in background or not.

ManagedThreadId is used to get unique id for the current managed thread.

Name is used to get or set the name of the current thread.

Priority is used to get or set the priority of the current thread.

ThreadState is used to return a value representing the thread state.

C# Thread Methods

A list of important methods of Thread class are given below:

Method Description

Abort() is used to terminate the thread. It raises ThreadAbortException.

Interrupt() is used to interrupt a thread which is in WaitSleepJoin state.

Join() is used to block all the calling threads until this thread terminates.

ResetAbort() is used to cancel the Abort request for the current thread.
Resume() is used to resume the suspended thread. It is obselete.

Sleep(Int32) is used to suspend the current thread for the specified milliseconds.

Start() changes the current state of the thread to Runnable.

Suspend() suspends the current thread if it is not suspended. It is obselete.

Yield() is used to yield the execution of current thread to another thread.

C# Main Thread Example


The first thread which is created inside a process is called Main thread. It starts first and ends at
last.
Let's see an example of Main thread in C#.

using System;
using System.Threading;
public class ThreadExample
{
public static void Main(string[] args)
{
Thread t = Thread.CurrentThread;
t.Name = "MainThread";
Console.WriteLine(t.Name);
}
}

Output:

MainThread
Thread Example: static method
We can call static and non-static methods on the execution of the thread. To call the static and
non-static methods, you need to pass method name in the constructor of ThreadStart class. For
static method, we don't need to create the instance of the class. You can refer it by the name of
class.

using System;
using System.Threading;
public class MyThread
{
public static void Thread1()
{
for (int i = 0; i < 10; i++)
{
Console.WriteLine(i);
}
}
}
public class ThreadExample
{
public static void Main()
{
Thread t1 = new Thread(new ThreadStart(MyThread.Thread1));
Thread t2 = new Thread(new ThreadStart(MyThread.Thread1));
t1.Start();
t2.Start();
}
}
Output:

0
1
2
3
4
5
0
1
2
3
4
5
6
7
8
9
6
7
8
9

The output of the above program can be anything because there is context switching between the
threads.

Thread Example: non-static method


For non-static method, you need to create instance of the class so that you can
refer it in the constructor of ThreadStart class.

using System;
using System.Threading;
public class MyThread
{
public void Thread1()
{
for (int i = 0; i < 10; i++)
{
Console.WriteLine(i);
}
}
}
public class ThreadExample
{
public static void Main()
{
MyThread mt = new MyThread();
Thread t1 = new Thread(new ThreadStart(mt.Thread1));
Thread t2 = new Thread(new ThreadStart(mt.Thread1));
t1.Start();
t2.Start();
}
}

Output:
0
1
2
3
4
5
0
1
2
3
4
5
6
7
8
9
6
7
8
9

Like above program output, the output of this program can be anything because there is context
switching between the threads.

Thread Example: performing different tasks on each thread


Let's see an example where we are executing different methods on each thread.

using System;
using System.Threading;

public class MyThread


{
public static void Thread1()
{
Console.WriteLine("task one");
}
public static void Thread2()
{
Console.WriteLine("task two");
}
}
public class ThreadExample
{
public static void Main()
{
Thread t1 = new Thread(new ThreadStart(MyThread.Thread1));
Thread t2 = new Thread(new ThreadStart(MyThread.Thread2));
t1.Start();
t2.Start();
}
}

Output:

task one
task two

Thread Sleep() method


The Sleep() method suspends the current thread for the specified milliseconds. So, other threads
get the chance to start execution.

using System;
using System.Threading;
public class MyThread
{
public void Thread1()
{
for (int i = 0; i < 10; i++)
{
Console.WriteLine(i);
Thread.Sleep(200);
}
}
}
public class ThreadExample
{
public static void Main()
{
MyThread mt = new MyThread();
Thread t1 = new Thread(new ThreadStart(mt.Thread1));
Thread t2 = new Thread(new ThreadStart(mt.Thread1));
t1.Start();
t2.Start();
}
}

Output:

4
4

Thread Abort() method


The Abort() method is used to terminate the thread. It raises ThreadAbortException if Abort
operation is not done.

Example

using System;
using System.Threading;
public class MyThread
{
public void Thread1()
{
for (int i = 0; i < 10; i++)
{
Console.WriteLine(i);
Thread.Sleep(200);
}
}
}
public class ThreadExample
{
public static void Main()
{
Console.WriteLine("Start of Main");
MyThread mt = new MyThread();
Thread t1 = new Thread(new ThreadStart(mt.Thread1));
Thread t2 = new Thread(new ThreadStart(mt.Thread1));

t1.Start();
t2.Start();
try
{
t1.Abort();
t2.Abort();
}
catch (ThreadAbortException tae)
{
Console.WriteLine(tae.ToString());
}
Console.WriteLine("End of Main");
}
}
Output:

Output is unpredictable because thread may be in running state.

Start of Main
0
End of Main

Thread Join() method


It causes all the calling threads to wait until the current thread (joined thread) is terminated or
completes its task.
using System;
using System.Threading;
public class MyThread
{
public void Thread1()
{
for (int i = 0; i < 5; i++)
{
Console.WriteLine(i);
Thread.Sleep(200);
}
}
}
public class ThreadExample
{
public static void Main()
{
MyThread mt = new MyThread();
Thread t1 = new Thread(new ThreadStart(mt.Thread1));
Thread t2 = new Thread(new ThreadStart(mt.Thread1));
Thread t3 = new Thread(new ThreadStart(mt.Thread1));
t1.Start();
t1.Join();
t2.Start();
t3.Start();
}
}
Output:
0
1
2
3
4
0
0
1
1
2
2
3
3
4
4

Naming Thread

You can change or get the name of the thread by using Name property of Thread class. Let's see
an example where we are setting and getting names of the threads.

using System;
using System.Threading;

public class MyThread


{
public void Thread1()
{
Thread t = Thread.CurrentThread;
Console.WriteLine(t.Name+" is running");
}
}
public class ThreadExample
{
public static void Main()
{
MyThread mt = new MyThread();
Thread t1 = new Thread(new ThreadStart(mt.Thread1));
Thread t2 = new Thread(new ThreadStart(mt.Thread1));
Thread t3 = new Thread(new ThreadStart(mt.Thread1));
t1.Name = "Player1";
t2.Name = "Player2";
t3.Name = "Player3";
t1.Start();
t2.Start();
t3.Start();
}
}

Output:
Player1 is running
Player2 is running
Player3 is running

ThreadPriority
In C# Programming Language, each and every thread has a priority that determines how often
the thread gets access to the CPU. In general, a Low-Priority Thread will get less CPU time than
a High-Priority Thread. The important point that we need to understand is how much CPU time a
thread will get, it doesn’t only depend on its priority, but also depends on the kind of operation it
is performing.
Let's see an example where we are changing the priority of the thread. The high priority thread
can be executed first. But it is not guaranteed because thread is highly system dependent. It
increases the chance of the high priority thread to execute before low priority thread.
Example
using System;
using System.Threading;
public class MyThread
{
public void Thread1()
{
Thread t = Thread.CurrentThread;
Console.WriteLine(t.Name+" is running");
}
}
public class ThreadExample
{
public static void Main()
{
MyThread mt = new MyThread();
Thread t1 = new Thread(new ThreadStart(mt.Thread1));
Thread t2 = new Thread(new ThreadStart(mt.Thread1));
Thread t3 = new Thread(new ThreadStart(mt.Thread1));
t1.Name = "Player1";
t2.Name = "Player2";
t3.Name = "Player3";
t3.Priority = ThreadPriority.Highest;
t2.Priority = ThreadPriority.Normal;
t1.Priority = ThreadPriority.Lowest;

t1.Start();
t2.Start();
t3.Start();
}
}

Output:
The output is unpredictable because threads are highly system dependent. It may follow any
algorithm preemptive or non-preemptive.
Player1 is running
Player3 is running
Player2 is running
Thread Synchronization
Synchronization is a technique that allows only one thread to access the resource for the
particular time. No other thread can interrupt until the assigned thread finishes its task.
In multithreading program, threads are allowed to access any resource for the required execution
time. Threads share resources and executes asynchronously. Accessing shared resources (data) is
critical task that sometimes may halt the system. We deal with it by making threads
synchronized.
It is mainly used in case of transactions like deposit, withdraw etc.

Advantage of Thread Synchronization


 Consistency Maintain
 No Thread Interference

C# Lock
We can use C# lock keyword to execute program synchronously. It is used to get lock for the
current thread, execute the task and then release the lock. It ensures that other thread does not
interrupt the execution until the execution finish.
Here, we are creating two examples that executes asynchronously and synchronously.

C# Example: Without Synchronization


In this example, we are not using lock. This example executes asynchronously. In other words,
there is context-switching between the threads.
using System;
using System.Threading;
class Printer
{
public void PrintTable()
{
for (int i = 1; i <= 10; i++)
{
Thread.Sleep(100);
Console.WriteLine(i);
}
}
}
class Program
{
public static void Main(string[] args)
{
Printer p = new Printer();
Thread t1 = new Thread(new ThreadStart(p.PrintTable));
Thread t2 = new Thread(new ThreadStart(p.PrintTable));
t1.Start();
t2.Start();
}
}

Output:
1
1
2
2
3
3
4
4
5
5
6
6
7
7
8
8
9
9
10
10

C# Thread Synchronization Example


In this example, we are using lock. This example executes synchronously. In other words, there
is no context-switching between the threads. In the output section, we can see that second thread
starts working after first threads finishes its tasks.
using System;
using System.Threading;
class Printer
{
public void PrintTable()
{
lock (this)
{
for (int i = 1; i <= 10; i++)
{
Thread.Sleep(100);
Console.WriteLine(i);
}
}
}
}
class Program
{
public static void Main(string[] args)
{
Printer p = new Printer();
Thread t1 = new Thread(new ThreadStart(p.PrintTable));
Thread t2 = new Thread(new ThreadStart(p.PrintTable));
t1.Start();
t2.Start();
}
}
Output:

1
2
3
4
5
6
7
8
9
10
1
2
3
4
5
6
7
8
9
10

Web Services in C#
Web Service is known as the software program. These services use the XML to exchange the
information with the other software with the help of the common internet Protocols. In the
simple term, we use the Web Service to interact with the objects over the internet.

Here are some points about the Web Service.


1. Web Service is not dependent on any particular language.
2. Web Service is a protocol Independent.
3. Web Service is platform-independent.
4. Web Service is known as the Stateless Architecture. These services are dependent only on
the given input.
5. Web Service is also Scalable.
6. Web Service is based on the XML (Open, Text-Based Standard).
Technology Used in Web Service
XML: Web Service specifies only the data. So, the application which understands
the XML regarding the programming language or the platform can format the XML in different
ways.
SOAP: The communication between the Services and the application is set up by the SOAP.
WSDL: WSDL gives us a uniform method that is helpful to specify the Web Services to the
other programs.
UDDI: With the help of UDDI, we can search the Web Service registries.
At the time of the deployment of these technologies, this allows the developers to do the
packaging of the applications in the form of the Service and publishing of the Service on the
network.

Advantages of Web Services


1. Web Services always use the open, text-based standard. Web service uses all those
components even they are written in various languages for different platforms.
2. Web Service promotes the modular approach of the programming so that the multiple
organizations can communicate with the same web service.
3. Web Services are easy to implement but expensive because they use the existing
infrastructure, and we can repackage most of the applications as the Web Service.
4. Web Service reduces the cost of enterprise application integration and B2B communications.
5. Web Services are the interoperable Organization that contains the 100 vendors and promote
them interoperability.

Limitations of Web Services


1. One of the limitations of the Web Services is that the SOAP, WSDL, UDDI requires the
development.
2. A support to the interoperability is also the limitation of the Web Service.
3. The limitation of web service is also royalty fees.
4. If we want to use web services for the high-performance situation, in that case, web service
will be slow.
5. The use of web service increases the traffic on the network.
6. The security level for Web Services is low.
7. We use the standard procedure to describe the quality of particular web services.
8. The standard for the Web Service is in the draft form.
9. To retain the intellectual property of the specific standard by the vendor is also the limitation
of the web service.
Example of the Web Service
Web Service can do almost any kind of task.
Web Portal: Web portal is used to fetch the headline news from the linked web service.
Weather Reporting: For the reporting of weather, we will use Weather Reporting Web Service
for displaying the information about the weather on our website.
Stock Quote: The latest information about the share market with the Stock Quote can display on
our website.
News headline: By using the news headline Web Service, we can show the latest update of the
news on our website.
We can make our web service and can give them back to use. Here we are taking an example like
we can make the Free SMS Sending Service with the footer for the company advertisement. So,
whenever any person uses this Service, they will indirectly advertise our company. For taking
advantage of the web service, we can apply the N number of ideas.
For creating the Web Service first, we will think about a scenario. For creating any web service,
firstly, we should have to get to know why we need Web Service.

The Need for Web Service


We will think about a scenario which we want to show on our website. On our website, we want
to show the information about the region, nation and about the international as well. Here if we
are thinking of writing the code for all these functionalities, this will take lots of time and the
effort to write the code for all these functionalities. All of the above information is already
provided by some existing sites, so in that case, we want to use that current logic of other sites.
But there is a problem arises how I could use the existing logic in my application.
The solution to this problem is Web Services.
By using the Web Service, we can reuse someone else's business logic, instead of replicating
this. To use the business logic of someone else, we just have to write a few lines of the code.
This technique is similar to the libraries of API, DLLs, and plug-ins.
The only difference between the libraries of API and the Web Service is that the Web Service is
located remotely on another server.
Web Services can be invoked by the other applications. Web Services are known as the pieces of
the business logic, which is hosted on the internet, and the other application can use them.
Here we have some points about the Web Services.
1. Web Services are not limited only to the .Net Framework. The standards of Web Services
were already defined before the release of the .NET. Web Services and supported by the vendors
other than Microsoft.
2. Web Services can also work on the cross-platform. If the services were written in one
language, these could be used by the other application despite, and the application used the other
language. If we want to use the web services, the only way for that is we only need the internet to
connect where we will make the HTTP request.
As we know that the Web Service is cross-platform, but despite this, there should be an
understandable language so that we can make a request for the services and can get the Service
in their response. Web Services use the XML, which can be understood easily.
This is the only reason why the web services were built with the XML based standards of
exchanging the data.
Web Services uses the Set of Data type. The XML Schema easily recognizes these data types.
Web Services uses a simple data type like strings and numbers. These data types are helpful for
communication with Web Services. And we cannot send the proprietary .NET objects like
image, FileStream, or the EventLogs. The other programming language does not have any way
to contact these .NET objects. If we use some devices to send them to the client, still the
different programming languages will not be able to interpret.
Note: If we want to work with the .NET objects, we can use the .NET remoting. .NET remoting
is known as distributed technology through which we can use the .NET objects. But the non-
.NET client can't use it.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy