Click here to Skip to main content
16,007,687 members
Home / Discussions / C#
   

C#

 
GeneralRe: Timed resize of image Pin
musefan6-Feb-09 3:43
musefan6-Feb-09 3:43 
GeneralRe: Timed resize of image Pin
m.otte6-Feb-09 3:49
m.otte6-Feb-09 3:49 
GeneralRe: Timed resize of image Pin
musefan6-Feb-09 3:53
musefan6-Feb-09 3:53 
GeneralRe: Timed resize of image Pin
m.otte6-Feb-09 5:31
m.otte6-Feb-09 5:31 
AnswerRe: Timed resize of image [modified] Pin
Luc Pattyn6-Feb-09 6:47
sitebuilderLuc Pattyn6-Feb-09 6:47 
GeneralRe: Timed resize of image Pin
musefan6-Feb-09 6:49
musefan6-Feb-09 6:49 
AnswerRe: Timed resize of image [modified] Pin
Luc Pattyn6-Feb-09 6:45
sitebuilderLuc Pattyn6-Feb-09 6:45 
QuestionFOR EXPERTS: Template Class: Type Constraints Pin
Axonn Echysttas6-Feb-09 2:12
Axonn Echysttas6-Feb-09 2:12 
Hey everybody... I got a question for advanced C# programmers. I've been playing around with type constraints for template classes, and I got stuck.
I used [ and ] instead of < and > for template classes because I wanted to have HTML code for you to see better what code I got.

In the C# 3.0 specification (and I will quote directly from Microsoft's document), it's said that this will work:

class B[T] where T: IEnumerable {...}
class D[T]: B[T] where T: IEnumerable {...}
class E[T]: B[List[T]] {...}


Because (so they say):

"Since type parameters are not inherited, constraints are never inherited either. In the example below, D needs to specify the constraint on its type parameter T so that T satisfies the constraint imposed by the base class B[T]. In contrast, class E need not specify a constraint, because List[T] implements IEnumerable for any T."

Now... I put this pre into VS 2008 and the compiler won't work. My pre:

class B[T] where T : IEnumerable[T] { }
class D[T] : B[T] where T : IEnumerable[T] { }
class E[T] : B[List[T]] { }


Error:

"Error 1 The type 'System.Collections.Generic.List[T]' cannot be used as type parameter 'T' in the generic type or method 'FunFollAdmin.frmMain.B[T]'. There is no implicit reference conversion from 'System.Collections.Generic.List[T]' to 'System.Collections.Generic.IEnumerable[System.Collections.Generic.List[T]]'. D:\Order\A1.FunFoll Administrator [FFA]\2009-01-25\FunFollAdmin\frmMain.cs 46 10 FunFollAdmin"

Even more......... not even this works:

B[test] test = new B[test]();


Error:

"Error 1 The type 'FunFollAdmin.frmMain.test' cannot be used as type parameter 'T' in the generic type or method 'FunFollAdmin.frmMain.B[T]'. There is no implicit reference conversion from 'FunFollAdmin.frmMain.test' to 'System.Collections.Generic.IEnumerable[FunFollAdmin.frmMain.test]'. D:\Order\A1.FunFoll Administrator [FFA]\2009-01-25\FunFollAdmin\frmMain.cs 216 9 FunFollAdmin
Error 2 The type 'FunFollAdmin.frmMain.test' cannot be used as type parameter 'T' in the generic type or method 'FunFollAdmin.frmMain.B[T]'. There is no implicit reference conversion from 'FunFollAdmin.frmMain.test' to 'System.Collections.Generic.IEnumerable[FunFollAdmin.frmMain.test]'. D:\Order\A1.FunFoll Administrator [FFA]\2009-01-25\FunFollAdmin\frmMain.cs 216 28 FunFollAdmin"

Even though I have implemented the class test correctly:

class test : IEnumerable[int]
{
  public test () { }
  #region IEnumerable[int] Members

  public IEnumerator[int] GetEnumerator ()
  {
    throw new NotImplementedException();
  }

  #endregion

  #region IEnumerable Members

  System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator ()
  {
    throw new NotImplementedException();
  }

  #endregion
}


-= E C H Y S T T A S =-
The Greater Mind Balance

Blending C++ with COM ^

Have a break on my website! Spread the word? Please?

AnswerRe: FOR EXPERTS: Template Class: Type Constraints [modified] Pin
Mirko19806-Feb-09 2:57
Mirko19806-Feb-09 2:57 
GeneralRe: FOR EXPERTS: Template Class: Type Constraints Pin
Axonn Echysttas6-Feb-09 3:40
Axonn Echysttas6-Feb-09 3:40 
GeneralRe: FOR EXPERTS: Template Class: Type Constraints Pin
Mirko19806-Feb-09 4:26
Mirko19806-Feb-09 4:26 
GeneralRe: FOR EXPERTS: Template Class: Type Constraints Pin
Axonn Echysttas6-Feb-09 5:19
Axonn Echysttas6-Feb-09 5:19 
GeneralRe: FOR EXPERTS: Template Class: Type Constraints Pin
Mirko19806-Feb-09 5:24
Mirko19806-Feb-09 5:24 
Questionconcateing strings in c# Pin
lawrenceinba6-Feb-09 1:32
lawrenceinba6-Feb-09 1:32 
AnswerRe: concateing strings in c# Pin
musefan6-Feb-09 1:38
musefan6-Feb-09 1:38 
GeneralRe: concateing strings in c# Pin
lawrenceinba6-Feb-09 2:57
lawrenceinba6-Feb-09 2:57 
GeneralRe: concateing strings in c# Pin
musefan6-Feb-09 3:15
musefan6-Feb-09 3:15 
GeneralRe: concateing strings in c# Pin
lawrenceinba6-Feb-09 5:51
lawrenceinba6-Feb-09 5:51 
GeneralRe: concateing strings in c# Pin
musefan6-Feb-09 6:02
musefan6-Feb-09 6:02 
AnswerRe: concateing strings in c# Pin
Guffa6-Feb-09 5:54
Guffa6-Feb-09 5:54 
GeneralRe: concateing strings in c# Pin
lawrenceinba6-Feb-09 6:35
lawrenceinba6-Feb-09 6:35 
AnswerRe: concateing strings in c# Pin
Guffa6-Feb-09 6:50
Guffa6-Feb-09 6:50 
GeneralRe: concateing strings in c# Pin
lawrenceinba6-Feb-09 7:02
lawrenceinba6-Feb-09 7:02 
GeneralRe: concateing strings in c# Pin
Guffa6-Feb-09 9:00
Guffa6-Feb-09 9:00 
GeneralRe: concateing strings in c# Pin
lawrenceinba6-Feb-09 9:05
lawrenceinba6-Feb-09 9:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.