p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Beginning Visual C# 2005 (http://p2p.wrox.com/forumdisplay.php?f=222)
-   -   what is asp.net (http://p2p.wrox.com/showthread.php?t=57002)

Larryz April 23rd, 2007 09:29 AM

what is asp.net
 
i am trying to do my mcad, with c#.....

i am confused i know the c# and j# for example can be used
to created websites with extensions aspx...

But what is asp.net...

c# can produce windows apps, so is not tied to .net.....

asp:button is that .net, i know there is more to it than this...

but i am trying to break it down into asp languages and what the other
bit is i am unsure..

Larry


dparsons April 23rd, 2007 08:24 PM

ASP.NET is the predecessor to the outdated ASP 3.0 Scripting language.

Where ASP was an interepeted language and *everything* was an object, asp.net is a compiled language which is much more akin to "real" programming then ASP was.

What I mean by real is having the ability to work with types and the like and not just declaring everything as an object so, to visualize:

ASP (VBScript)
Dim sValue
sValue = "This is a string"

ASP.NET (VB and C#)
Dim sValue as String = "This is a String"
string sValue = "This is a string";

So, essentially, ASP.NET is the replacement for ASP and as such it does not require the user to have the .NET framework installed on their machine, it simply must be installed on the server and IIS must be configured to execute aspx files.

By default, if IIS is already installed when you go to install the framework this will be done automatically but, if the framework is installed before iis you need to run a command prompt (start --> run --> cmd) navigate to the .NET folder (typically %systemdrive%\windows\microsoft.net\framework\[version]) once there execute aspnet_regiis -i which will configure IIS to execute aspx pages.

This line I don't understand: "c# can produce windows apps, so is not tied to .net....."

So I am not sure if you mean to imply that C# is not tied to ASP.NET or that ASP.NET is not tied to the .NET Framework?? But, in any case, C# can be used to develop windows apps, WindowCE apps, Web Services, asp.net applications, etc. (The same goes for VB.NET or J#)

<asp:Button id="btn" runat=server /> is ASP.NET and when placed on a Web Form it will render an plain old HTML button at run time and, you are correct, there is much more to it then this but its really outside the scope of one thread to break it all down. (Wrox has numerous books on this subject that you might want to check out)

hth^^

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
================================================== =========
Why can't Programmers, program??
http://www.codinghorror.com/blog/archives/000781.html
================================================== =========

Larryz April 24th, 2007 07:53 PM

Thanks that was a good explanation...... But...
I was wondering by learnng visual c#, which can be used to develope asp.net applications..... Are you learning asp.net and c# or bits of both..

i am trying to understand ok i can learn language, but what bits of it make it asp.net and what bits make it just part of the language....

for example int i; that could be used in an asp.net application... it doesnt do much but you can be sure that some integers will be declared in most application... windows or otherwise....

What i mean is c# is not asp.net... nor is vb6..... so what is it..

Larry...


dparsons April 24th, 2007 09:19 PM

Ok. C# is a language (as is VB, J# etc) all that that is is a bunch of Syntax that when executed inside of the .NET framework does some task.

ASP.NET on the other hand is a TECHNOLOGY that allows us to do different things on the web that simply are possible with HTML, DHTML, etc. By learning visual C# you are learning visual C# and the book will dictate in what context you are learning it (Platform Based vs Web Based) but once you know C# there are only slight difference's between writing a windows app and an ASP.NET app.

For example, you can't try to spawn a form from the the System.Windows.Forms Assembly in an ASP.NET application.

hth.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
================================================== =========
Why can't Programmers, program??
http://www.codinghorror.com/blog/archives/000781.html
================================================== =========

Larryz April 25th, 2007 07:46 AM

thats great... i was stuck on that for a while cheers.. I guess its self evident really, due to books on c# and asp.net, the same title with vb, etc.. Asp being the constant.

thanks a lot...

i wonder if i may as you a few more questions.

What is a interface in terms of oop..... i have just started and having problems with all this. i have worked out what a class is, and done some coding but cant figure out this interface thing..... its just as abstract as some of the other terminology at the moment....

thanks for all your help

Larry


dparsons April 25th, 2007 08:17 AM

This is a good read in understanding Interfaces.
http://www.c-sharpcorner.com/UploadF...7-54717ef3b345

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
================================================== =========
Why can't Programmers, program??
http://www.codinghorror.com/blog/archives/000781.html
================================================== =========

Larryz May 3rd, 2007 04:16 AM

Its seems that when you create a new object of your own design
certain methods seems to be defined automatically for it....

ToString() for example...

This is confusing, for me at least..

You can do things like myObject.ToString();

What is this doing...

why do you want to do that

i mean if you have an object, which is an instance of a class
this is odd..

why say for example myObject.Name, here you force the object to
return the Name field using the get { return name }, for example.

or you can call other defined publicly available methods. which you define and implement...

So why then allow myObject.ToString() although not implemented in object... it doesnt make sense to me... myObject.ToString() its like trying to convert the entire thing to a string.. and for what purpose..

Also the books says abstract classes cant be instantiated but
what does that mean.... I thought it meant you cant create an instance of it...but only derive from it... but you are partly creating and instance of it when you store fields values in it.... via a derived object.

Larry confused again , no change there then.. :)


dparsons May 3rd, 2007 06:48 AM

hmm. About your class, are you deriving it from another class? Because, given this code:

using System;
using System.Collections.Generic;

namespace foo
{
    class foo
    {
    
    }
}

The only properties that I can access through something like

{
foo.[property]
}

is Equals and ReferenceEquals (which determines if 2 objects are equal) BUT if i change my class to this

namespace foo
{
    class foo
    {
        public static string fooString()
        {

        }
    }
}

I can do

foo.fooString().ToString(); (This is obviously pointless since fooString returns a string but, at this point, you are accessing all of the properties of the string type since that is what the function returns)

I hope that helps you.

Abstract Classes, as you said, can not be instantiated they MUST be inherited. By inheriting from an abstract class you are not instantating it but doing this:

MyClass foo = new MyClass();

Where MyClass is marked as abstract, this line of code will throw an error since are you explicitly instantiating the object with the intent to work with it directly as opposed to inherting from it.

hth.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
================================================== =========
Why can't Programmers, program??
http://www.codinghorror.com/blog/archives/000781.html
================================================== =========

Larryz May 3rd, 2007 10:26 AM

So when you create a basic class,
For example
namespace mynamespace
{
public class myClass
{
 public string Name;
get
}
return name;
}
set
{

name = value;
}
public myClass()
{
//default constructor
}
public myClass(string objName)
{

}
}


here no methods have been defined, purposely....

Later we can try in console application....

class Program
{
static void Main(string[] args)
{
 myClass myObj = new myClass("Fred");
myClass.ToString();
// is possible because of inheritance ???????

}
}
}


}


dparsons May 3rd, 2007 11:00 AM

I am sorry, no. I misunderstood you. In my example I was referencing the static properties of my foo object in the above code.

When You create an instance of an object and then call the .ToString() method, what this does is it gives you a human readable string of what the object is.

For example doing:
Object o = new Object();
Console.WriteLine(o.ToString());

Will print out System.Object.

On the flip side:
int i = 0;
Console.WriteLine(i.ToString());

will return 0.

In your example above, calling .ToString should return: mynamespace.myClass

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
================================================== =========
Why can't Programmers, program??
http://www.codinghorror.com/blog/archives/000781.html
================================================== =========

Larryz May 3rd, 2007 05:57 PM

Thats an excellent explanation..... thanks.. no one else responds to my questions they must be lame lol..... i mean not they my questions must be....

i have kinda worked out what colllections are, but finding indexers hard..and the concept in general, i get its a collection of objects etc.....


eg public mycollection this[int mycollectindex]
// what is the this refering to...
{
get
{
return (mycollection) List[mycollectindex];
}
// here i guess it returns mycollection with the index value mycollectindex ?

set
{
List[mycollectindex] = value;
// what is this returning
}

in this code....
from the book ...... page 282
Animals is a collection...
Animals animalCollection = new Animals();
animalCollection.Add(new cow("jack"));
animal is an object allowing cow to be derived from it
what confuses me is the call to Add which an Animal object..
i am assuming the obect is first create via the code...new cow("jack") which it will look at the Animal object to see what to do.... and then that object jack is added to the collection... otherwise it wont know what object jack is in order to add it......?

}


dparsons May 3rd, 2007 11:06 PM

In so far as people in here being Lame, that isn't the case. There are alot of skilled contribtors here (Imar, Peter, Joe, Happy, etc) and if I wasn't answering your questions, I am sure one of them would be! ;]

Anyway, about collections.

I don't have the book that you are referencing so what I am going to do is explain this using an array list and the DataTable object.

ArrayList arr = new ArrayList();
arr.Add(new DataTable("foo"));

Now, depending on what I am doing and what the use of this particular collection is I can do something like:

foreach(DataTable t in arr)
{
//do something with each object in the collection
}

Your get statement is returning the object at the given index your set statement doesn't return anything, it sets the specified index with the supplied value.

hth

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
================================================== =========
Why can't Programmers, program??
http://www.codinghorror.com/blog/archives/000781.html
================================================== =========

Larryz May 4th, 2007 06:38 AM

thats great but i dont have a clue of what a DataTable is....

i am , the newbie here...

Anyway i have worked out basicly a collection in terms of the book is a collection of obejects... which different from an array of objects..

eg Animal[] animalArray = new Animal[2];

Its uses and arraylist..
ArrayList AnimalArrayList = new ArrayList();
this ArrayList together with CollectionBase allows collections to be created ....

But i am not sure of all that... a cleaner explanation than the book would, be Very helpfull.....

thanks in advance ..Larry .


dparsons May 4th, 2007 09:07 PM

Hmmm. You have lost me.

An arraylist implements these interfaces: ICollections, IEnumerable, IList, and ICloneable

This is what gives it the ability to create a Collection of objects; for example: when you call Arraylist.Add[value] the Add property is defined in the IList interface and then implemented inside of the System.Collections.ArrayList class to provide this functionality.

I am sorry but i am not sure if i have answered your question. =
================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
================================================== =========
Why can't Programmers, program??
http://www.codinghorror.com/blog/archives/000781.html
================================================== =========

Larryz May 6th, 2007 12:59 PM

OK a slight change in topic

Ordinary properties and indexers i am kind of stuck by syytax
and understanding how they work....

An ordinary property, maybe defined as follows.


public int myProperty

get
{
 return myInt;
}
set
{
myInt = value;
}

In the above example, we may call it
via
myobject.myProperty = 6;

hence using the set branch to set the value..

we use the name myProperty to set that property and we can see
from the property signature that it will set an integer value.

public int myProperty

i hope i am making sense ....

But take this example...

public Animal this[int animalIndex]
// This is a special property called and indexer..
// it is used in object collections
get
{
 return (Animal) List[animalIndex];
}
set
{
  List[animalIndex] = value;
}

The confusing bit for me..... is

A) The signature of the property

Ordinary properties and indexers i am kind of stuck by syytax
and understanding how they work....

An ordinary property, maybe defined as follows.



public int myProperty
//its public it sets an integer type the name is myProperty.
// we explictly call it.. to use it.

get
{
 return myInt;
}
set
{
myInt = value;
}

In the above example, we may call it
via
myobject.myProperty = 6;

hence using the set branch to set the value..

we use the name myProperty to set that property and we can see
from the property signature that it will set an integer value.

public int myProperty

i hope i am making sense ....

But take this example...

public Animal this[int animalIndex]

Animal is s class so its not the name
and its not called directly as in the above example
how does the compiler know that
when for example
            animalsCollection[2] = new chicken("franky")
to use this indexer...
In the normal property we call it via its name....

and point B
I dont get the property signature of the indexer

public Animal this[int animalIndex]
What are all these bits ...What is Animal what is this[in animalIndex]

i cant break down the signature as i did for ordinary properties.

There isnt a name for the property as such in the signature.

All i can think of is the object name is the name and it takes and index.
and it sets an object type of Animal.



Larryz May 7th, 2007 08:09 AM


Posted - 05/06/2007 : 11:42:54 PM Show Profile Email Poster Edit Topic Send Larryz an AOL message Reply with Quote Delete Topic
public void CopyTo(Cards targetCards)
      {
         for (int index = 0; index < this.Count; index++)
         {
            targetCards[index] = this[index];
         }
      }

The code above is called via objectName.CopyTo(cards)
cards is an collection....

what is the this refering to... is it... objectName.count, where objecctName is a collection.

thanks Larry..



All times are GMT -4. The time now is 12:01 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.