Home
Get Started
Learn
Downloads
AJAX
MVC
Community
Wiki
Forums
Sign in
|
Join
Home
›
ASP.NET Forums
›
Search
Search
You searched for the word(s): userid:630950
More Search Options
RSS Available
Matching Posts
Re: Generic T
i try to modify the code by not specifing "as T" then i get the below error and if i have "as T" then T is null Error 1 Cannot implicitly convert type 'System.Collections.Generic.List<Person>' to 'T' public T Get(long id) { List<Person> _p = new List<Person>(); DataAccess da = new DataAccess(); _p = da.GetAllPeople(); //as T; return _p; }
Posted to
Getting Started
(Forum)
by
nisarkhan
on 11/24/2009
Generic T
I am trying to return the Generic T and its returning null not sure what i'm missing in the below code, any help ? here is my code // public interface IRepositoryGenericT<T> where T : class { T Get(long id); IList<T> GetAll(); void Save(T target); void Delete(T target); } public class RepositoryGenericT<T> : IRepositoryGenericT<T> where T : class { public RepositoryGenericT() { } public T Get(long id) { //id ignore for testing purpose... List<Person> _p = new List<Person>
Posted to
Getting Started
(Forum)
by
nisarkhan
on 11/24/2009
Re: Generic T
[quote user="anphme"] The reason that null is being returned is because you are trying to cast a List<Person> as a Person at line 20 and it is failing. There is no built-in conversion of an enumerable type to a non-enumerable type. Try returning the first item in the list (since you are instanciating RepositoryGenericT with type Person at line 48, you do not need to cast the list item). [/quote] I try to change the code as what you have suggust but getting error here is the modified
Posted to
Getting Started
(Forum)
by
nisarkhan
on 11/24/2009
Re: Generic T
i change the dataaccess class to accept Generic T but still returning null public class DataAccess<T> where T : class { public T GetAllPeople() { List<Person> persons = new List<Person> { new Person("joe - Memory", "Jatson - Memory", 27), new Person("Ge - Memory", "Page - Memory", 23) }; return persons as T; } } probably i am casting to T ? but if I dont cast it throw me an error: Cannot implicitly convert type 'System.Collections.Generic
Posted to
Getting Started
(Forum)
by
nisarkhan
on 11/24/2009
Re: Generic T
i am kind of lost now after reading your last post so my GetAllPeople is nothing but: public class DataAccess//<T> { public List<Person> GetAllPeople() { List<Person> persons = new List<Person> { new Person("joe - Memory", "Jatson - Memory", 27), new Person("Ge - Memory", "Page - Memory", 23) }; return persons; } } public class Person { public Person(string firstname, string lastname, int age) { Firstname = firstname; Lastname = lastname;
Posted to
Getting Started
(Forum)
by
nisarkhan
on 11/24/2009
Re: IENumerable selecting indexes
have you tried Element or ElementAt ?
Posted to
C#
(Forum)
by
nisarkhan
on 11/6/2009
Re: video training course
you can try appdev.com but bit expensive thou or learnvisualstudio.net is cheap and best but they rarely updat their videos.
Posted to
Book Reviews
(Forum)
by
nisarkhan
on 10/26/2009
Re: videos better than books?
[quote user="Nelson85"] Do you think videos are better than books? [/quote] video to get quick start and then later you can read book to get into more detail.
Posted to
Book Reviews
(Forum)
by
nisarkhan
on 10/26/2009
Re: IQueryable
i saw those post before i posting here and i dont find what i'm curious to know.
Posted to
Data Access and ObjectDataSource Control
(Forum)
by
nisarkhan
on 10/22/2009
Re: linq2sql whats wrong here?
[quote user="gunteman"] In that case IEnumerable is the right choice, but isn't "Id" the primary key? Can sp_Visit(Id) really return more than one? PS. You should not name procedures with "sp_", it's reserved for MSSQL internal system procedures. It will actually become a bit slower, since the master database will be checked automatically, due to the prefix. [/quote] "sp_" i use just to for the purpose of highlighting that i'm using stored procedure
Posted to
Architecture
(Forum)
by
nisarkhan
on 10/21/2009
Page 1 of 136 (1351 items) 1
2
3
4
5
Next >
...
Last »
Channel 10:
How to Use "Play to" and "Remote Media Streaming" in Windows 7
TechNet Edge:
Managing Your Entire World - Tech Focus November 2009 Part 3
Channel 10:
Show Us Your Tech - Mark Pendergrast Edition
TechNet Edge:
Mark Russinovich interview at TechEd EMEA 09
TechNet Edge:
IT Manager Podcast #31: Talking About Virtualization
TechNet Edge:
System Center Operations Manager 2007 R2 – Service Level Dashboard part 1: Introduction
WindowsClient:
MSXML XHTML DTDs - making the web better
TechNet Edge:
How it works: Active Directory Rights Management Services
Channel 9:
Inside Windows 7: Recovering Windows from System Degradation and Boot Failures
Channel 10:
Ebay Launches IE8 Webslice for Holiday Shopping
Channel 10:
New Windows Smartphone Includes Built-in PowerPoint Projector
Channel 10:
Bing's Top Searches Reveal Our Celeb Obsessions
Channel 9:
Ping 39: Chrome is here, Dancing in MS Stores, Iphone & Bing
ASP.NET:
Building Twitter Search using the ASP.NET Ajax Library Beta – Part 1
Silverlight:
Using Azure as a Silverlight Streaming replacement
Silverlight:
Building extensible Silverlight applications with MEF
TechNet Edge:
Joachim Nässlander on Live Migration
ASP.NET:
T4MVC 2.6: MVC 2 Areas support
ASP.NET:
Script# Update - v0.5.5.0
Channel 10:
Difference between DirectX 10 and DirectX 11
Microsoft Communities
ASP.NET
Channel 8
Channel 9
Channel 10
IIS.NET
Silverlight
TechNet Edge
WindowsClient
Mix Online