Friday, June 27, 2014

Difference between Dispose and Finalizer

The finalizer method is called when your object is garbage collected and you have no guarantee when this will happen (you can force it, but it will hurt performance).
The Dispose method on the other hand is meant to be called by the code that created your class so that you can clean up and release any resources you have acquired (unmanaged data, database connections, file handles, etc) the moment the code is done with your object.
The standard practice is to implement IDisposable and Dispose so that you can use your object in a using statement. Such as using(var foo = new MyObject()) { }. And in your finalizer, you call Dispose, just in case the calling code forgot to dispose of you.

Trick to square a number.

If number is divisible by 5. This is very easy to get the square of such number.


Suppose it is a two digit number:
xy = (x* (x+1)) (y*y)


Example:
15 = 1*(1+1)    (5*5) =  (1*2) 25 =  225
25 = 2*(2+1)    (5*5) =  (2*3) 25 =  625
35 = 3*(3+1)    (5*5) =  (3*4) 25 = 4225
45 = 4*(4+1)    (5*5) =  (4*5) 25 = 2025
125 = 12*13     (5*5) = 15625


Trick to get the Square of other numbers that are below than hundred
xy =   x*(xy+y)+Carry + (y*y)


Example
12 = (1*(12+2) +0) (2*2) =( (1*14)+0)  4 = 144
13 = (13+3) (3*3) = 169
14 = (14+4) (16)  = 196 (Carry will be 1 that will add in 18)
15 = (15+5) (25) = 225
21 = 2*(21+1) (1)= 441
22 = 2*(22+2) (2*2) = 484
26 = 2*(26+6) (6*6) =  676
32 = 3*(32+2) (2*2) =  1024

Friday, June 20, 2014

Interview.

1) What are table object?
2) What global variable and temporary variables in SQL server?
3) If two tables related with priamary key and foreign key  and we want to update/insert some column values from primary table that write the query.
4) If we have a same method in child class and base class than.


Chid objChild = new Base();
objChild.Display();


What will be the output?

Ans : Base class method would be called.

Friday, June 13, 2014

Remoting

  1. Describe in detail Basic of SAO architecture of Remoting?
  2. Remoting has at least three sections :
    • Common Interface which will be shared between them.
    • Server.
    • Client.
  3. Here is an explanation of the process:
    • First important section is the common interface between Server and Client. For sample project interface
    • is very simple with only two methods : SetValue and GetValue.
    • Public Interface InterFaceRemoting
    • Sub SetValue(ByVal value As String)
    • Function GetValue() As String
    • End Interface
    • Second important section is the server. In this sample server is using HTTP channel and the server object is singleton.
    • Imports System
    • Imports System.Runtime.Remoting
    • Imports System.Runtime.Remoting.Channels.Http
    • Imports System.Runtime.Remoting.Channels
    • Imports InterFaceRemoting
    • Public Class RemotingServer Inherits MarshalByRefObject
    • Implements InterFaceRemoting.InterFaceRemoting
    • Private strData As String
    • Public Function GetValue() As String Implements
    • InterFaceRemoting.InterFaceRemoting.GetValue
    • Return strData
    • End Function
    • Sub New()
    • strData = "testing.."
    • End Sub
    • Public Sub SetValue(ByVal value As String) Implements
    • InterFaceRemoting.InterFaceRemoting.SetValue
    • strData = value
    • End Sub
    • End Class
    • Module ModuleRemotingStartUp
    • Sub Main()
    • Dim objHttpChannel As HttpChannel
    • Console.WriteLine("Server Started...")
    • objHttpChannel = New HttpChannel(1234)
    • ChannelServices.RegisterChannel(objHttpChannel)
    • RemotingConfiguration.RegisterWellKnownServiceType(GetType(RemotingServer),
    • "RemoteObject", WellKnownObjectMode.Singleton)
    • Console.WriteLine("Server registered and listening waiting for clients...")
    • Console.ReadLine()
    • End Sub
    • End Module
    • In the code above, Channel object is created and registered. Server then hosts the object so that client can connect to it. This is the time when we specify what mode the server object will be created i.e. Singleton or SingleCall. This is done by the following below given code. Note in sample we are hosting the server object in singleton mode that means that the same object
    • will be shared between all clients. Also note the server object is implementing "InterFaceRemoting" and inheriting from "MarshalByRefObject".
    • RemotingConfiguration.RegisterWellKnownServiceType(GetType(RemotingServer),
    • "RemoteObject", WellKnownObjectMode.Singleton)
    • In the last section the client will connect to this hosted remoting object.
    • Imports System
    • Imports System.Runtime.Remoting
    • Imports System.Runtime.Remoting.Channels.Http
    • Imports System.Runtime.Remoting.Channels
    • Imports InterFaceRemoting
    • Module ModuleStartClient
    • Sub Main()
    • Dim objHttpChannel As New HttpChannel
    • Dim objRemoting As InterFaceRemoting.InterFaceRemoting
    • ChannelServices.RegisterChannel(objHttpChannel)
    • objRemoting =
    • CType(Activator.GetObject(GetType(InterFaceRemoting.InterFaceRemoting),
    • "http://localhost:1234/RemoteObject"),
    • InterFaceRemoting.InterFaceRemoting)
    • Console.WriteLine("Referenced the main object.... Now displaying Data")
    • Console.WriteLine("Value on server :- " & objRemoting.GetValue.ToString())
    • Console.WriteLine("Press enter to Terminate")
    • Console.ReadLine()
    • End Sub
    • End Module
    • Finally you need to run server and then client.

Friday, June 6, 2014

Web Sevice

What are Web Services?

  • Web services are small units of code
  • Web services use XML based communicating protocols
  • Web services are independent of operating systems
  • Web services are independent of programming languages

XML Based Web Protocols

Web services use the standard web protocols HTTP, XML, SOAP, WSDL, and UDDI.

HTTP

HTTP (Hypertext Transfer Protocol) is the World Wide Web standard for communication over the Internet. HTTP is standardized by the World Wide Web Consortium (W3C).

XML

XML (eXtensible Markup Language) is a well known standard for storing, carrying, and exchanging data. XML is standardized by the W3C.


SOAP
SOAP (Simple Object Access Protocol) is a lightweight platform and language neutral communication protocol that allows programs to communicate via standard Internet HTTP. SOAP is standardized by the W3C.

WSDL

WSDL (Web Services Description Language) is an XML-based language used to define web services and to describe how to access them. WSDL is a suggestion by Ariba, IBM and Microsoft for describing services for the W3C XML Activity on XML Protocols.

UDDI

UDDI (Universal Description, Discovery and Integration) is a directory service where businesses can register and search for web services. UDDI is a public registry, where one can publish and inquire about web services.

Followers

Link