|
|
If you already have a background in VB then try just reading the spec at:
CSharpSpecStart
As far as book, I liked Apress' Pro C# 2005 and the .NET 2.0 Platform. I think it is a great book for those who already know programming but don't know the C# lanagauge.
|
|
|
|
|
Hope this[^] link will be more Useful when you wnat to learn C#.
Regards,
Satips.
|
|
|
|
|
Hello All,
Thank you very much for providing some useful urls.
Thanks & Regards,
Kumar
|
|
|
|
|
I decided to make my life much harder than it is and convert some C++ code I have to C# (and possibly Java some day).
Please - no "Why do that you dummy" responses, that serves no purpose. Also, with NO EXCEPTIONS there isno single tool to take a C++ code set, reverse it to a complete UML model and re-engineer it into C# (there are numerous tools that kinda do parts, but still leave too much work. I figured out that a combination of 6(six) yes 6 tools will provide that process at a total cost to myself of too much (money and effort).
Lastly, C++ has too much complexity and I refuse to pander to it anymore than I must - AND I DO NOT WANT TO WRITE MY OWN PARSER for all the crap that's snuck into it.
Actually I'm answering some personal questions I have about development and processes in general and this seemed like a good test. Also I have a large body of "real" C++ code I'd like to rebuild in C# and I'm working on a methodology and VS tools to do it.
I selected this specific code for specific reasons and is quite large and complex (its the source code to a windows based RTS game from a few years back), and I think I have a handle on most issues.
However ....
I would like suggestions as to how to gracefully handle the following situations:
(what I'm currently doing in parens)
- TYPEDEF's (So far I've punted and done a global Search and Replace)
- Macros (Utility functions)
- Unions (distinct structs, remodelled use)
- const (removed and ignored)
Any physiologically possible solutions gratefully received and considered. If you have any additional problems in this (such as struct inheritance) please let me know.
If I get the time I'll post an article on this subject (with attributions) - I can't be the only person wishing for a NET/C# alternative to some of the s****y C++ code out there. Nor the only person who wants tools to make it more efficient.
Nothing is impossible, we just don't know the way of it yet.
|
|
|
|
|
"- TYPEDEF's (So far I've punted and done a global Search and Replace)"
- I think this is the only practical way to handle typedef. You can replace certain simple cases with the C# alias syntax "using Foo = x.y.z".
"- Macros (Utility functions)"
- We handle it with search/replace combined with replacement with the simple C# flag type #define (the flag #define allows the converted #ifdef FOO directives to continue to be useful). One problem is that macros are type-less, so it's problematic to refactor these to static methods.
"- const (removed and ignored)"
- Yes, they must be removed, but they provide information for a C++ to C# conversions (especially for parameters).
C++ to C# (or to any other language) is indeed no picnic (we've recently released 'C++ to C# Converter', which eases the task somewhat, but there's just too much complexity in the C++ language to allow a high conversion rate).
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
C++ to C# Converter: converts C++ to C#
C++ to VB Converter: converts C++ to VB
Instant C++: converts C# to C++/CLI and VB to C++/CLI
Instant Python: converts C# to IronPython and VB to IronPython
|
|
|
|
|
Valid point regarding the const - the information IS important to C++ but can be dealt with at the C# model level (remove the need).
I looked at the demo - fairly nice tool but addresses pure conversion only.
A very real secondary need (almost at the same level as pure translation) is the ability to place the C++ code into a UML model - not just the class diagrams, but sequence etc diagrams too. Then I can "Fix" some issues of the basic model, perform package management, remodel the design, etc, and regenerate/test.
I would suggest you look at CodeVizualizer (http://www.codedrawer.com/ - $50) which is a great tool for learning individual code segments but doesn't have the ability to generate all documentation I require/need for analysis, nor does it provide the big picture.
I would highly recommend it for a utility tool for a C++ maintenance/enhancement project, but it falls short of being a "corporate" architect tool.
Nothing is impossible, we just don't know the way of it yet.
|
|
|
|
|
I have a class that handles encryption of passwords, and there is one part where I want to fill a structure with the following:
struct RoleValue
{
public string szRoleName;
public string szDialog;
public string szAdd;
public string szView;
public string szEdit;
public string szDel;
public string szDialogDescr;
}
public ArrayList RoleDialogAccess = new ArrayList();
//Fill the structure with data from the SQL query...
while (sqlRdr.Read())
{
rm.szRoleName = sqlRdr.GetString(0);
rm.szDialog = sqlRdr.GetString(1);
rm.szView = sqlRdr.GetString(2);
rm.szAdd = sqlRdr.GetString(3);
rm.szEdit = sqlRdr.GetString(4);
rm.szDel = sqlRdr.GetString(5);
rm.szDialogDescr = sqlRdr.GetString(6);
this.RoleDialogAccess.Add(rm);
}
This is all good.
When I get to VB is where the problem occurs.
For VB.NET to be able to access the data, I have to do the following:
Dim AEG as New AESClass
rw(0) = CStr(Me.AEG.RoleDialogAccess.Item(iCnt).szDialog)
rw(1) = CStr(Me.AEG.RoleDialogAccess.Item(iCnt).szDialogDescr)
rw(2) = CStr(Me.AEG.RoleDialogAccess.Item(iCnt).szAdd)
rw(3) = CStr(Me.AEG.RoleDialogAccess.Item(iCnt).szView)
rw(4) = CStr(Me.AEG.RoleDialogAccess.Item(iCnt).szEdit)
rw(5) = CStr(Me.AEG.RoleDialogAccess.Item(iCnt).szDel)
Now, in when done in Visual Studio 2005 there is no problem, but when I place the C# DLL into a VB Project in migrated (from VS 2003)
on XP the compiler crashes and on NT 2000 I get errors. Nothing specific about the errors, ones that must be sent to Microsoft.
What am I doing wrong?
"I know not with what weapons World War III will be fought, but World War IV will be fought with sticks and stones."
Einstein
|
|
|
|
|
Not enough info. to really diagnose the problem, but ..
Looking at the VB code I can see strict isn't on. I'm guessing explicit isn't on either given the state of the code
If both projects are in VS2005 then perhaps you could declare RoleDialogAccess as List<rolevalue> instead? The VB class could then consume it such:
( where Me.AEG.RoleDialogAccess is List(Of RoleValue) )
AEG.RoleDialogAccess(iCnt).szDialog
.
.
.
Might help.
------------------------------------------------
I'm largely language agnostic -
After a while they all bug me
------------------------------------------------
|
|
|
|
|
I have the situation where Form A is hidden when Form C is displayed and then when Form C is closed, Form A is displayed again. Almost all of the time it works as expected. Occasionally, though, both forms are seen displayed at the same time. For the most part, no one can tell me the steps they went through when it happens. It has been witnessed mostly in debug mode. The one time it happened in release mode was also the one time we knew the steps that led it to happen - a test procedure was being run. However, when the test procedure was repeated at a later date the 2 windows were correctly mutually exclusive. Any ideas?
Description of the code:
When ClassB is instantiated, it sets the member variable m_FormCOpen = false. Later, upon user selection, FormA will call method1 in ClassB. method1 instantiates FormC, subscribes to the closed event for FormC, sets m_FormCOpen = true, displays FormC, does some database updating, and returns. The method in FormA checks the property for m_FormCOpen and if it is true, hides FormA. The method in ClassB that is executed when FormC closes, triggers an event to which FormA has subscribed, and FormA is displayed.
public class FormA
{
public FormA (ClassB)
{
m_ClassB = ClassB;
}
private void ClassA_Load ()
{
subscribe to ClassB ClosedFormC – routine to call: ClassB_ClosedFormC.
}
private void UserSelection_Click()
{
m_ClassB.method1();
If FormCIsOpen
{
Hide();
}
}
ClassB_ClosedFormC()
{
Show();
}
}
public class ClassB
{
public void ClassB()
{
m_FormCOpen = false;
}
public void method1()
{
FormC m_FormC = new FormC();
subscribe to FormC.Closed – method to call FormC_Closed
m_FormCOpen = true;
m_FormC.Show();
do some stuff
}
private void FormC_Closed
{
trigger ClosedFormC
m_FormCOpen = false;
}
bool FormCIsOpen
{
get
{
return m_FormCOpen;
}
}
}
|
|
|
|
|
Hi,
I am not surprised it behaves strangely:
the "code" shown is a complete mess; it is not valid C# code, and it is convoluted.
Why have variables m_FormC, m_FormCOpen and FormCIsOpen all side-by-side ?
It would be much better to have just one m_FormC somewhere, and one method to determine
whether this m_FormC is open or not, rather than having several bools that try to keep
track...
|
|
|
|
|
I realize it is not valid C# code - I said it was a "Description" of the code. I did not put it in red as the code tag would do, and I mentioned that it works most of the time. If this were truly the 'code', it would not be compiling far less working most of the time. The true code has been executed by 11 people, 6 hours a day, for 2 years. In that time the error situation I am describing has occurred about 4 times. The code itself sits on another computer and is too voluminous to reproduce here. This is not a syntax problem. If someone is on the level where they could answer this question, I think they are at the level they can fill in the blanks in the outline and perfect C# is not needed.
I don't know what you mean by side-by-side and what that has to do with how code executes. The 3 items you mention serve different purposes. m_FormC is the class itself. m_FormCOpen is the boolean that tracks whether the form is dipslayed or not. Remember, the class can be instantiated but the form not necessarily displayed at a given time. FormCIsOpen is the property which allows other classes access to the member variable m_FormCOpen. Thus, you see, there are not several bools that try to keep track - there is only one. There are reasons why one class displays the form and another needs to know if it is displayed or not. The question is, that being the case, is there a safer way to accomplish it. Or, is there a known Windows/.NET problem where forms in hiding suddenly come out of hiding. You haven't given a meaningful alternative or any explanation for why the methodology here would fail.
My impression is you were too quick to respond. Slow down. If you don't want to take the time to understand something that isn't immediately obvious to you, it would be better to not respond at all than to do so in a nonconstructive manner. Saying the code is a complete mess is not constructive. Confusing a class with a bool with a property is not constructive. But, if you were truly trying to be helpful, then thanks for taking the time.
|
|
|
|
|
A form knows whether it is visible or not, there is no need to try to keep that in a boolean.
Less code = less bugs
Better readability = better code
|
|
|
|
|
For this design, there is. Note that 'the boolean' is in ClassB - not FormC. FormC does know when it closes, but method1 has already finished its execution by this time. FormC alerts others to its closing via an event. ClassB sets the boolean based on this event. ClassA can now access the information via a property provided by ClassB. ClassB has visibility to FormC. FormA does not. Thus, FormA cannot ask FormC are you open or closed.
|
|
|
|
|
Well... I realize that this is not the real code, but rather a pseudo code of it...
However, it looks like this code is not thread-safe.
This means that there might be a chance that sometimes, under certain circumstances, m_FormCOpen is misleading your program because of thread-safety issues.
If you don't know what "thread-safe" means, I'de suggest reading on the following topics:
- Thread Safety
- Threads Synchronization
- Locking Mechanisms.
Good luck,
Shy.
|
|
|
|
|
Here's a theory:
If someone clicks twice in FormA fast enough for the second click to be queued before the form is hidden, it would open two instances of FormC. When closing one of the instances, FormA would be shown.
You can prevent multiple instances of FormC to be opened:
private void UserSelection_Click() {
if (!m_ClassB.FormCIsOpen) {
m_ClassB.method1();
if (m_ClassB.FormCIsOpen) {
Hide();
}
}
}
---
single minded; short sighted; long gone;
|
|
|
|
|
This is a very good theory - especially from the excerpt I put out. I had greatly simplified UserSelection_Click. The selection comes from a VS 2003 data grid - the code is determining a double click based on MouseUp, etc. Things stop, i.e., the clock doesn't start for a second double click, until method1 has completed, so I don't think this is exactly the problem. Maybe something similar to what you are describing is happening earlier in the pipe, though. I just haven't been able to find it yet. And, your code suggestion is good to put in as a fail-safe. If nothing else, if the problem pops up again with this code in, then it will narrow down the possibilities some more. Thanks.
|
|
|
|
|
Fix turned out to be:
Application.DoEvents();
Hide();
|
|
|
|
|
I'm creating C# WinForms client-server database application.
This application reads data from PostgreSQL server using npgsql Dataadapter and DataReader classes and stores data mostly in Datasets and sometimes in business object properties.
A lot of lookup tables (payment terms, currency list etc) are static.
Currently application reads them from server always over TCP connection.
This makes application slow.
How to cache data in client side ?
Where to find caching module for .NET application ?
It it reasonable to use .NET 2 Web Cache object for this ?
Web Cache object doc says that it is designed only for ASP .NET application.
Is it reasonable to use it in WinForms application or are there better
caching object available.
I cannot use MS Caching application block since my application needs to run in
Linux also.
Andrus
|
|
|
|
|
AndrusM wrote: How to cache data in client side ?
Where to find caching module for .NET application ?
Have you looked at the Enterprise Library?
AndrusM wrote: I cannot use MS Caching application block since my application needs to run in
Linux also
I take it that it doesn't compile in Mono then?
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
* Reading: Developer Day 5
Never write for other people. Write for yourself, because you have a passion for it. -- Marc Clifton
My website
|
|
|
|
|
I this I can compile in under MONO since this is open source.
However Microsoft licence prohibits its using on non-windows environment.
Is it reasonable to use AppDomain cache:
AppDomain.CurrentDomain.SetData("key", value);<br />
DataSet ds = (DataSet)AppDomain.CurrentDomain.GetData("keyname");<br />
or are there any better soluton ?
Andrus
|
|
|
|
|
We know the label in DevExpress .NET v7.1 controls can change its forecolor augomatic when the skin changed.But I found that the checkedit can not change its forecolor augomatic when the skin changed.
My question is How to change the checkedit's forecolor augomatic when the skin changed.
Thanks a lot!
|
|
|
|
|
You are seeking assistance with a third party tool. DevExpress has their own support forums, you should seek assistance there.
Here are the forums: http://www.devexpress.com/Support/Forums.xml[^]
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
* Reading: Developer Day 5
Never write for other people. Write for yourself, because you have a passion for it. -- Marc Clifton
My website
|
|
|
|
|
Hi
plz if anyone can help
this is the code
{
string str = "bahaa";
int result = Convert.ToInt32(x);
}
it gives an exception "Input string was not in a correct format."
|
|
|
|
|
??
there is something wrong I think.
Convert.ToInt32() normally takes a string; I dont know what x is.
if you meant Convert.ToInt32(str);
then obviously that would fail because str does not look like a number at all.
|
|
|
|