TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Michael
NA
7
0
C# Generics
Oct 3 2007 4:36 AM
I have just setup my first class using generics, I'm not too sure if I have it set up incorrect, or possibly using it for the wrong purpose.
The class is as follows.....
using Microsoft.DirectX;
using Microsoft.DirectX.Direct3D;
namespace Breakfast3D.Graphics.ContentManager
{
public class ContentObject<ContentType>
{
private string _file;
private string _label;
private Device _device;
private ContentType _content;
public string FilePath { get { return _file; } }
public string Label { get { return _label; } }
public ContentType Content { get { return _content; } }
public ContentObject(Device device, string label, string file)
{
_device = device;
_file = file;
_label = label;
}
public void LoadResource()
{
if (_content is Texture)
_content = TextureLoader.FromFile(_device, _file);
}
public void UnloadResource()
{
}
}
}
The error im recieving is....
Cannot implicitly convert type "Direct3D.Texture" to "ContentType"
(
_content = TextureLoader.FromFile(_device, _file);
)
The class is instantised with this code...
_contentManager.AddResource<Texture>("texture1", "texture1.jpg");
public static void
AddResource<ContentType>
(string label, string file)
{
ContentObject<ContentType>
_content =
new ContentObject<ContentType>
(_device, label, file);
_content.LoadResource();
_register.Add(label, _content);
}
Any thoughts, I've looked around different sites at tutorials on generics, but most of them used the same tutorial, with the same examples.
Any help greatly appreciated.
Reply
Answers (
6
)
How to set the font?
Is there a fast way to convert a bitmap image to a grayscale or binary image?