|
If your classes are not sealed, you can create a derived class that points to the most used case.
For example:
public sealed class List:
List<object>
{
}
(the List<T> must not be sealed, the new class can be sealed).
Or, at the unit where you must use the type a lot, you can create a using.
For example:
using MyClass = System.Collections.Generic.List<string>
The main problem with this case is that when you declare a using clause you must always use the full path of every type.
|
|
|
|
|
Excellent. I just create a private nested class for each of the super generic types. It will be relieving to encapsulate all of that craziness.
Never mind, I can't do that. This is enough to make me switch to C++ permanently.
modified on Wednesday, November 25, 2009 3:15 PM
|
|
|
|
|
How about:
public class MyComplexList: NodeHeap<Node<SimplePathFinder<TTileMap, TTile, TData>, TTileMap, TTile, TData>,
SimplePathFinder<TTileMap, TTile, TData>, TTileMap, TTile, TData>
{
};
MyComplexList openList = new MyComplexList();
|
|
|
|
|
I was about to do that, until I realized that it wouldn't work the way I intend because many methods take arguments that require the complex generic types. They are all intertwined.
Its a complex situation with no solution other than to suck it up. I'm very disappointed.
|
|
|
|
|
Make an alias with a using directive?
CaptainSeeSharp wrote: use #define like I could in C
Yeah, you could do that; I pass my C# through C pre-processor (just because I can).
|
|
|
|
|
PIEBALDconsult wrote: I pass my C# through C pre-processor (just because I can).
Are you a Linux user?
Greetings - Jacek
|
|
|
|
|
|
A little insight into the classes would let me be more sure, but I'm guessing that you have more generic parameters than you need. Also, this is a great place to use var
I would guess that you could declare the classes something like this:
class Node<TTileMap, TTile, TData>
{
private SimplePathFinder<TTileMap, TTile, TData> finder;
private TTileMap map;
private TTile tile;
private TData data;
}
class NodeHeap<TTileMap, TTile, TData>
{
private Node<TTileMap, TTile, TData> _nodes[];
}
var opelList = new NodeHeap<TTileMap, TTile, TData>();
|
|
|
|
|
Here is a quick glimpse...
public class SimplePathFinder<TTileMap, TTile, TData>
where TTileMap : TileMap<TTile, TData>
where TTile : Tile<TData>, new()
where TData : struct
{
#region Fields
private Dictionary<TData, byte> m_resistanceDict;
private byte[] m_resistanceMap;
private Node<SimplePathFinder<TTileMap, TTile, TData>, TTileMap, TTile, TData>[] m_openListRegestry;
private TTileMap m_workingMap;
private Node<SimplePathFinder<TTileMap, TTile, TData>, TTileMap, TTile, TData> m_startNode, m_endNode;
private bool _allowDiaginals;
private bool _updated;
private Coordinate[] _currPath;
private uint _currPathIndex;
...
public class Node<TAStarAlg, TTileMap, TTile, TData> : IEquatable<Node<TAStarAlg, TTileMap, TTile, TData>>, IComparable<Node<TAStarAlg, TTileMap, TTile, TData>>
where TAStarAlg : SimplePathFinder<TTileMap, TTile, TData>
where TTileMap : TileMap<TTile, TData>
where TTile : Tile<TData>, new()
where TData : struct
{
.....
public static bool operator ==(Node<TAStarAlg, TTileMap, TTile, TData> a, Node<TAStarAlg, TTileMap, TTile, TData> b)
{
return Object.Equals(a, b);
}
....
public class NodeHeap<TNode, TAStarAlg, TTileMap, TTile, TData>
where TNode : Node<TAStarAlg, TTileMap, TTile, TData>
where TAStarAlg : SimplePathFinder<TTileMap, TTile, TData>
where TTileMap : TileMap<TTile, TData>
where TTile : Tile<TData>, new()
where TData : struct
{
#region "Fields"
private Node<TAStarAlg, TTileMap, TTile, TData>[] m_nodeHeap;
private uint m_lastNodeIndex;
#endregion
.....
|
|
|
|
|
Hello,
I want to learn how a windows is drawn by the system. The reason for doing this is that I want to create a whole interface my self. I want to change the window's frame, close button etc. Hope you guys are understanding me . Can anyone point me to a tutorial on how i can do this please?
|
|
|
|
|
A tutorial? A really don't know.
But there are many things to understand.
First, if you want to draw the window interface yourself but will still use windows from the operating system, simple create a borderless window, and draw everything you need in it.
Second, if you want to create a full "window support" yourself, you will need to understand how to create and group regions. But by the type of the question I think you only need the first one.
|
|
|
|
|
So in the first one what you mean is that i draw the titlebar close button etc with GDI?
|
|
|
|
|
Yes... you can even create your own controls that look and behave like the title-bar.
|
|
|
|
|
Hi,
I am looking for some help in integrating my UI designer with Visual Studio. The idea is silmiar to VS Class designer or Entity designer.
1. when the file is select, the designer is open.
2. it updates the file when the visual elements are changed.
3. it generates source code file. One visual elements represents one class. When the visual elements change, the source code also change accordingly. for example, the element is renamed, then the class name is changed and all reference are changed automatically like renaming a class in Visual Studio.
Any information is appreciated.
Thanks
Carey
|
|
|
|
|
Hi, instead u can create ur own designer that will accept name and type and location, those u can save to XML,DB. and afterwords u can draw the form at runtime as u want. even u can change the design of form at runtime via refreshing the XML or DB.
Avinash S. Godse
|
|
|
|
|
Hi,
Is there any benifit to create a string as shown below.
string strTemp = new string(new char[21]);
sttTemp = string.Format("{0}", "test");
Thanks,
Chary.
|
|
|
|
|
No.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
No, in fact it's worse.
Strings are immutable. This means once they are created they can't be changed.
The first line creates an empty string.
The second line creates a new string from your two literals, and assigns the variable to this new string.
If you're very lucky, the compiler might optimise the extra creation out as it's not used, but even then your left back where you started with just 1 creation.
Just do it the normal way.
String myString = "test";
Simon
|
|
|
|
|
System.String is immutable, which means once they get created, they cannot change. Every new assignment results in a new string being created and the reference to the new string object assigned to the variable.
Those constructors exist to assist you in creating strings from already created char arrays, etc.
|
|
|
|
|
As the others have said, there is no benefit - in fact yours is about as bad as it can get, as it creates up to 4 strings:
1) new string(new char[21])
2) "{0}"
3) "test"
4) strTemp = ...
It may produce four if it doesn't "spot" that string.Format("{0}", "test") is the same as "test". Optimisation will almost certainly reduce this to one, but it makes your code look like it is written by a beginner, whether you are one or not!
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
"Rumour has it that if you play Microsoft CDs backwards you will hear Satanic messages.Worse still, is that if you play them forwards they will install Windows"
|
|
|
|
|
Yes, but not if you're just going to throw it away in the next line.
|
|
|
|
|
Data Source=SERVER\SSGSQL;Initial Catalog=myDatabase;User Id=sa;Password=abc123;
I am trying to install SQL SErver 2008 Express on WIndows Server 2008 64-bit. Installation was successfull and i am able to use the sql sever on the server with no issuie but when connecting from another machine using the above connection string I get this error though I enabled the TCP/IP and Name Pipes and the login method is Mixed and Firewall is accepting 1433 port:!
TITLE: Connect to Server
------------------------------
Cannot connect to SERVER\SSGSQL.
------------------------------
ADDITIONAL INFORMATION:
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) (Microsoft SQL Server, Error: 1326)
For help, click: http:
------------------------------
BUTTONS:
OK
------------------------------
|
|
|
|
|
just one note..
I have disabled the firework and now i am able to connect from the client to the remote through sql management studio..
but where is the issue if the port 1433 and the sqlserv exe is already added?
|
|
|
|
|
Hello!
I'd like to create little system for mobile phones which can recognize speech. There are two ways to do it, first is to have speech recognition on mobile phone (however I've got difficulties with using PocketSphinx, if you'd like me to, I can explain what exactly), the other is to have speech recognition on server and just have mobile phone connecting to that server with the use of Skype. The communication between devices and applications would be as follows: Skype on mobile phone calls Skype on server -> Skype on server redirects the speech (with the use of server application) to speech recognition engine Sphinx4 -> Sphinx4 recognizes the speech and answers to Skype (do I need to do it through the server application?). Recently I've been working on creating acoustic model for Sphinx4.
I have already found some good code which I can use in my application: http://forum.skype.com/index.php?showtopic=260361&st=0&p=1158301&#entry1158301 . However I don't have the experience in writing server applications. (I've got some experience in C++, Free Pascal and Visual Basic but I'm rather newbie in C#). Can you suggest me how to begin with writing this server application? I would appreciate it if you can give me some useful materials to read, tutorials or advices.
Greetings!
|
|
|
|
|
Hi folks...
hope someone can help. I created a simple UserControl in a C# Project (VS9) that basically consists of a Label placed on that Usercontrol.
The following happens:
1) place the Usercontrol "Label" via designer on another UserControl "Parent"
2) change the Fontsize of "Label" to another value (e.g. from 9,25 to 14,75)
3) see the "Label" Control is relocated from original position to a new position on "Parent".
It seems to me that the control is relocated due to some scaling issues but I can't figure out what exactly is the problem. I am sure it is no big thing, I need the Usercontrol "Label" to stay in place instead of beeing relocated automatically in design view. Any ideas?
|
|
|
|
|