Object to Object Initialization in C#.net

Hi, I want to Initialization the the base class object to derived class object. but it gives an error in c#.Net.

It's works fine in VB.Net bt in c#.net dosn't work.

what exactly i m doing as follows;

class class1

{

pubic int i;

}

class class2 : class1

{

// some method ....

}

in the main function.

static void main()

{

class1 c1 = new class1();

class c2;

c2=c1; // this is  not workin in c#.net alougth it's woks fine in vb.net

class c2 = new class1(); // i don't want  like this.

is there any onther way in c# to acheive this. please help me..

}


Sandeep Sharma
0
sa
6/13/2007 3:59:56 AM
asp.net.getting-started 91979 articles. 3 followers. Follow

3 Replies
1061 Views

Similar Articles

[PageSpeed] 47

Hi There,

I think this article would help you ;)

http://www.codeproject.com/dotnet/CheatSheetCastingNET.asp

 


DC517
Don't forget to click "Mark as Answer" on the post that helped you.
This credits that member, earns you a point and marks your thread as Resolved.
0
d4dennis
6/13/2007 4:46:06 AM

 

Hi, thanx for replying. i got some ideas. bt still wit as keyword it's not working.

it's show null value.

is there any other solution......


Sandeep Sharma
0
sa
6/13/2007 5:48:54 AM

 Hi There,

I don't think the way you do it is the right way.

sa.sharma:

class class1

{

pubic int i;

}

class class2 : class1

{

// some method ....

}

in the main function.

static void main()

{

class1 c1 = new class1();

class c2;

c2=c1; // this is  not workin in c#.net alougth it's woks fine in vb.net

class c2 = new class1(); // i don't want  like this.

is there any onther way in c# to acheive this. please help me..

}

I know you can do the following:

Class2 c2 = new Class2();

Class1 c1 = (Class1)c2;

But not following, because it is wrong casting

Class1 c1 = new Class1();

Class2 c2 = (Class2)c1;

unless casting with same type

Class1 c1 = new Class2();

Class2 c2 = (Class2)c1;

 


DC517
Don't forget to click "Mark as Answer" on the post that helped you.
This credits that member, earns you a point and marks your thread as Resolved.
0
d4dennis
6/13/2007 6:32:41 AM
Reply:

Similar Artilces:

.Net 2.0 Web application using Vb.net is unable to create object of another dll writen in C# .net 2.0
Hi, I habe created one ASP.net web application using Vb.net which is adding reference of dlls written in C# and .net 2.0. But whenever trying to create object of referencing dll, it is throwing error :Object reference does not set to an object. But, locally it is working fine,. In the server i have deployed the .aspx files and dll files in the bin. There were already an web.config in the server which is of .net 1.1. But checked it is retrieving value for that web.config correctly. Should i have to deply any other files and if not what can be the solution for this? Please help. Thanks, So...

get Subreport object in c#.net
i have a collection of reports and i want to distinguish the subreport from that collection and want to display that subreport.. Hi, You can't show the subreport alone, to display the subreport, a parent report must be exited and only in this way does it make sense, and it belongs to the parent report file. Thanks.Michael Jin.Microsoft Online Community SupportPlease remember to mark the replies as answers if they help and unmark them if they provide no help....

Replace the .NET 1.1 Behavior-Object with the .NET 2.0 Tag-Object , How to?
Hello, to set the Style - Attribute of my custom controls tag in source view from within its designer i use now the following code:Behavior.SetStyleAttribute("Left", false, val, true);This works fine but my visual studio 2005 / asp.net 2.0 says that the Behavior object is obsolete. The recommended alternative is the Tag object. But when i use it to set the Style attribute it doesn't work . I can set all other attributes or even create new ones using this Tag object but it does'nt work for the style attribute at all. What am i doing wrong? If I can't set the style attribute in my custom contr...

Sending SMS using vb.net or C#.net using vb.net or c#.net
Hi  My requirement is I hav one csv file with these fields id,mobilenum,messgae,status.intiallu staus is 0. once i read the all fileds and take that mobile number.using tat mobile number  i need to send sms .after sending sms i shuld change status as 1 How to send sms thru coding (please dont provide any links.if it is provide also please give working links becox i checked codeproject .i didnt get any nice link. and also provide the how to update the status field im csv file   Thank ssandhya   To send SMS, you need some third party SMS providers. if you consul...

use VB.NET and C#.NET code in the same C#.NET project
All-- Here is a sample that is "off the beaten path", (at least for me). Is it possible, in an ASP.NET application, using the code-behind page building technique, to have both pages written in VB.NET and pages written C#.NET?At http://www.WebLogicArts.com/DemoList.aspx there is a sample that shows that, (contrary to popular belief), it IS possible to mix ASP.NET pages built with C#.NET with ASP.NET pages built with VB.NET in the same VS.NET 2003 project. Note that this is just a "fun" sample to see if it can be done and I do not recommend this practice as a "standard" way of develo...

Deploying .Net application with datawindow .Net objects
Hi I=92ve been testing datawindow .net for our company by building a small working application using the Datawindow .Net tutorial. It works great (both from the VS interface and the compiled solution .exe) and was easy to create. My next test is to try and deploy this application to another machine, which has the .Net (1.1) environment but no Powerbuilder or Visual Studio. I built my solution and placed these files, all in one folder, on this other machine: datawindow.dll datawindow.xml DataWindowInterop.dll MSVCP71.DLL MSVCR71.DLL PBDATA100.dll PBDWN100.DLL PBO10100.D...

Which object does remember the dataset object in .net for distribution case?
Hi, If I use dataset to connect to database server which disconnects to DB after loading the data then call open method of connection to connect again. How does the database server or certain object know which dataset it is? how does it work internally? Thanks a lot!    I am not certain exactly what you mean, but perhaps this will help.  A DataSet is a disconnected data store, it never knows nor cares about where it came from.  A Data Adapter (for the appropriate provider, such as Sql DataAdapter, OleDbDataAdapter) is required to get data into the data...

converting to vb.net from c#.net authorize.net
authorize.net offered me some sample code when I signed up with them the only problem is the sample code is in c#.net but my page that they type all of their credit card into is vb.net <code><%@ Import Namespace="System.Net" %> <%@ Import Namespace="System.IO" %> <script language="C#" runat="server"> void Page_Load(Object Src, EventArgs E) { myPage.Text = readHtmlPage("https://certification.authorize.net/gateway/transact.dll"); } private String readHtmlPage(string url) { ...

How to get .net band object from javascript?
Hello, We have created a band object through .Net 2.0. We need to get object of that band obect and access its method through javascript. The purpose behind is, without going to server and we should access .Net Objects functionality from client side itself. The .Net objects in the form of Band on the client's browser. Could you give me the steps to achieve this task?   Thanks, R.Umasankar      I don't know what a "Band" object is, but the only things that you can pass back and forth to/from the server are strings, so you would nee...

.NET Object
I have writen an object for my Business Logic layer that contains a method that returns a data table.(Much like seen In the 3-tier tutorial BLL)  I would like to use this for my crystal report but I cannot see the fields that are returned from my method when trying to add a .NET Object data source In the Crystal Reports Database Expert.  My method also contains a parameter to query results.  I was wondering if anyone could tell me how to go about doing this or a good alternative I could go directly to my data set I just would preffer to use the Business Logic Layer for everyth...

How to access Mozilla Objects from .NET C#
Hi All,I have been dying to develop an automation suite for Mozilla browser. The suite should be able to open the browser, navigate to the URL and perform actions like click and etc. I guess it could be achieved by mozctl.dll which comes with the mozilla activex control v1.7.12. The MozillaBrowser class inside the mozctl.dll has the necessary functions like navigate and document etc which can be used to get the control over the elements inside the DOM. The major issue I am facing is, when I write the code\ MozillaBrowser m = new MozillaBrowser(); m.Navigate(“Yahoo.com”, ref o, ref ...

C# more object oriented than VB.net ???
I have a few related questions Is C# more object oriented than VB.net ??? Why do we need C# in the first place ?? Was'nt VB.net enough ??? Is C# there for the sake of adding object-orientedness to .net ?? Someone asked me how come .net is object oriented...I did answer him but I'd like to hear more from you people Thanks, > Is C# more object oriented than VB.net ??? No. They are precisely as object-oriented as one another. For the most part, they differ only in syntax, not in function. > Why do we need C# in the first place ?? .NET gave Microsoft a chance to ...

com objects (in C++) not working with .net?
I have the following code in a .asp file <% Dim obj1 obj1 = CreateObject("MYOBJ") %> The same code in a VBasp.net page Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim obj1 obj1 = CreateObject("MYOBJ") End Sub returns the error: "Server Application Unavailable The web application you are attempting to access on this web server is currently unavailable. Please hit the "Refresh" button in your web browser to retry your request" "a...

Innovation to ADO.NET
Matisse Software Inc. provides its native ADO.NET Data provider for Matisse 6.0, the Database for .NET. Matisse Software has pushed the envelope of Microsoft ADO.NET architecture and extended it into a powerful Object Access Services component for .NET. Matisse’s extension of ADO.NET demonstrates that ADO.NET can evolve beyond the Microsoft architecture to benefit .NET developers. Unlike the standard ADO.NET data provider, which returns data in a table format to integrate seamlessly with relational products, Matisse has extended the ADO.NET architecture to return data in an object format....

Web resources about - Object to Object Initialization in C#.net - asp.net.getting-started

Initialization vector - Wikipedia, the free encyclopedia
is a fixed-size input to a cryptographic primitive that is typically required to be random or pseudorandom . Randomization is crucial for encryption ...

Booting an Intel Architecture System, Part I: Early Initialization
The boot sequence today is far more complex than it was even a decade ago. Here's a detailed, low-level, step-by-step walkthrough of the boot ...

Patent US6061520 - Method and system for performing static initialization - Google Patents
... consolidating class files, the preloader identifies all &lt;clinit&gt; methods and play executes these methods to determine the static initialization ...

Tisdale on model initialization in wake of the leaked IPCC draft
Should Climate Models Be Initialized To Replicate The Multidecadal Variability Of The Instrument Temperature Record During The 20th Century? ...

Spring Environment is for initialization code only - Java Code Geeks
Since version 3.1, the Spring framework offers an abstraction towards several different sources through which you can easily configure your application: ...

Ball Invasion for iPad2 for iPad on the iTunes App Store
Get Ball Invasion for iPad2 on the App Store. See screenshots and ratings, and read customer reviews.

Stack Overflow
Stack Exchange log in - careers - chat - meta - about - faq Questions Tags Users Badges Unanswered Ask Question Top Questions interesting 325 ...

IBM System/360 - Wikipedia, the free encyclopedia
. It was the first family of computers designed to cover the complete range of applications, from small to large, both commercial and scientific. ...

ESANN - Author index
Electronic preceedings author index ESANN - European Symposium on Artificial Neural Networks [ Electronic proceedings home page ] A B C D E F ...

Using event capturing to improve Basecamp page load times
... would be best if we could avoid initializing sortables until the last possible moment, just before you start to drag a to-do. Deferring Initialization ...

Resources last updated: 12/5/2015 11:00:54 PM