473,322 Members | 1,699 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

method type ICollection returns Dataview

Hello :O)

Im in the process of learning asp.net, and i'm reading a nice book. But then
suddenly i came across this:

public ICollection DataLoad()

{

DataTable dtEmployee = new DataTable();

DataRow drEmployee;
dtEmployee.Columns.Add(new DataColumn("emp_id",
System.Type.GetType("System.Int16")));

dtEmployee.Columns.Add(new DataColumn("emp_name",
System.Type.GetType("System.String")));

drEmployee = dtEmployee.NewRow();

drEmployee["emp_id"] = 1;

drEmployee["emp_name"] = "E.E. Smith";

dtEmployee.Rows.Add(drEmployee);
dvEmployee = new DataView(dtEmployee);

return dvEmployee;

}

The method type is ICollection but it returns a DataView - what's the
purpose of that? The caller then casts it as a DataView in order to use it,
is't a normal approach or? And what about overhead with all that
typecasting?

Kind regards
Nov 18 '05 #1
1 1815
Hi,

Since DataView implement ICollection therefore the function can return
DataView. the idea behind such code is flexibility. Every function can
call that method, expect ICollection as result and work against
ICollection defined methods and properties. This way of programming
enables DataLoad users to work with that function even if you change
function implementation, because programmers works against Interface
Natty Gur[MVP]

blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)52-8888377
*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: andrew.miadowicz | last post by:
It's funny that I've only now run into this question, after a few years of using C#, but I find it intriguiging all the same. All the more so, that the generic version of ICollection in .Net...
1
by: Ryan McLean | last post by:
Hi everyone! What is happening is the method: sub_btnSubmitClicked is being executed every time any other object with a Handler is executed. I am trying not to use the withevents and handles...
2
by: Grigs | last post by:
I have a C# Web Service that some of the methods (ones that return integers) work and some do not (the ones that return a DataView. Here is some code in the WebService that is giving me the...
1
by: Will | last post by:
I have a web method in my web service that I would to have a command object passed in as a parameter. But when I compile the service I get the following error: You must implement the...
4
by: Terry | last post by:
Hi, I am both new to .Net (coming from VB6 and DAO) and to this news group. I am trying to convert some code from VB6 that uses a "record set" to help the user locate a specific record. As the...
2
by: Khurram | last post by:
Hi, Get the following error when trying to create a method that returns a one-dimentional array. You must implement a default accessor on System.Array because it inherits from ICollection. ...
3
by: =?Utf-8?B?UHVjY2E=?= | last post by:
Are there any good built-in or availble functions that I can call to sort my dataset datatalbe based on 1 or more of the table's columns? -- Thanks.
4
by: =?Utf-8?B?R3JlZw==?= | last post by:
I am a newbie to WCF so please forgive if this is an obvious question. I have the following. (Service contract) IEmployee public interface IEmployee { List<EmployeeGetEmployeeByID(string...
2
by: Tony | last post by:
Hello! According to the documentation we have the following interface IList : ICollection, IEnumerable { I can understand all the methods in this IList } interface ICollection : IEnumerable...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.