|
I developed an Installer using C# set up project. Now when i try to repair it instead of removing it, still it removes the product. what can i do so - when i say it to repair, it will repair the software?
Chayan
|
|
|
|
|
Sorry to ask a new question so soon , I managed to get the xml working now ive got a simple question im sure ive done this before but im getting confused with my actionscript .
so ive got CurrentStatus.InnerText = "Away"; now im just trying to remember how to create a vaeriable like i would in actionscript string i think it is
CurrentStatus.InnerText = Value;
and then value = "away" in the button click events
gah i cant belive ive forgotton this sorry
|
|
|
|
|
That sounds just about right.
-Larantz-
|
|
|
|
|
Hi,
Has anyone written or have found code that creates a Queue(FIFO) and Stack(FILO) class without using System.Collections (1.1) and without using generics(2.0)
Any sample code will be much appreciated.
Thanks
happy coding!
|
|
|
|
|
Why don't you want to use the built-in types? The non-generic collections are implemented in mscorlib.dll, which you cannot build a .NET program without referencing, so in effect they're 'free'. Generic collections are implemented in System.dll, but it's almost impossible not to use some functionality from this assembly, so again it's effectively free.
Both classes are based on arrays, so if you grow the stack or queue beyond the largest size you've previously used you will incur some time cost as it allocates a new array and copies the elements from the old to the new array.
If you just want to study the code for these classes, get the Shared Source version from here[^].
|
|
|
|
|
Mike Dimmick wrote: Why don't you want to use the built-in types?
I imagine he doesn't want to use the built in classes as his homework question started with
"Without using the built in classes...."
"More functions should disregard input values and just return 12. It would make life easier." - comment posted on WTF
|
|
|
|
|
Once upon a time there was no .NET and people used to create their own data structures
(such as linked lists) in whatever language they preferred or had available.
now there is .NET and a lot of fancy programming languages, and yes you still can
create linked lists: come up with a Node class, and let one Node point to the next
(and maybe also to the previous one); then design a Push() and a Pop() method, et voila
you have either a Queue or a Stack.
Alternatively, create an ArrayList class yourself: use an array, and if an Add() operation
would exceed the array's length, allocate a new and larger one, copy the data and move on.
And then turn that ArrayList into a Stack (it would not serve well in a Queue).
No big deal, no magic involved.
|
|
|
|
|
using System;
using System.Collections.Generic;
using System.Text;
namespace ClassLibrary1
{
public class bank
{
private int _accno;
private string _acctype;
private int _balance;
private int _amount;
public int accno
{
get
{
return _accno;
}
set
{
_accno = value;
}
}
public string acctype
{
get
{
return _acctype;
}
set
{
if (_acctype = "savings" || _acctype = "current")
{
_acctype = value;
}
else
{
_acctype = "";
}
}
}
public int balance
{
get
{
return _balance;
}
}
public int amount
{
get
{
return _amount;
}
set
{
_amount = value;
}
}
public int credit(_balance , _amount)
{
return _balance + _amount;
}
public int debit(_balance , _amount)
{
return _balance - _amount;
}
}
}
hi
|
|
|
|
|
what error message are you getting? Did you declare the constructor in your class?
happy coding!
|
|
|
|
|
iam getting identifier expected
hi
|
|
|
|
|
OK, Can you do the following:
1. Take out System.Collections for time being
2. Add the default constructor like public Bank(){}.
3. Comment out all your properties get and set methods.
4. Start building the code and start uncommenting each of the properties and then see what error message you get and at what stage , this will enable to to understand the problem better.
Sorry cann't help more than this because don't have IDE in front of me,
Hope you sort out your problem,
happy coding!
|
|
|
|
|
Visual Studio will show numbers at the left of your source lines for you, and the
error messages it generates include file name and line number; look at the first error
you have, go investigate that particular line, (try to) fix it and recompile. Until
everything is OK.
|
|
|
|
|
What are you expecting it to do? What are you getting that you don't think you should? Are you getting some sort of error?
Ben
|
|
|
|
|
Change this part of your code
if (_acctype = "savings" || _acctype = "current")
{
_acctype = value;
}
else
{
_acctype = "";
}
to this
if (_acctype == "savings" || _acctype == "current")
{
_acctype = value;
}
else
{
_acctype = "";
}
-Larantz-
|
|
|
|
|
Just as an aside --
public int credit(_balance , _amount)
{
return _balance + _amount;
}
public int debit(_balance , _amount)
{
return _balance - _amount;
}
These two functions have parameter names that hide the private members - so if you are trying to make the function use your actual balance instead of a balance that is passed in, they should be declared as:
public int credit(_amount){/*code*/}
and
public int debit(_amount){/*code*/}
And if you want the balance to actually be updated, you'll need to do _balance -= _amount; or _balance += _amount;
(this is assuming that you actually do want it to be updated)
|
|
|
|
|
You need to fix your acctype property
public string acctype
{
get { return _acctype; }
set
{
if (value == "savings" || value == "current")
{
_acctype = value;
} else { _acctype = String.Empty; }
}
}
|
|
|
|
|
Ok, after looking at your code, AND the other replies, there are areas that do have real problems.
LOGICAL ERROR:
public string acctype
{
get { return _acctype; }
set {
if (_acctype = "savings" || _acctype = "current")
{
_acctype = value;
}
else
{
_acctype = "";
}
}
}
In your test, you are assigning the strings to _acctype, what you accomplish will not be what you want, as _acctype will always be assigned the contents of value.
QUESTIONABLE on what you are attempting to do:
public int credit(_balance , _amount)
{
return _balance + _amount;
}
public int debit(_balance , _amount)
{
return _balance - _amount;
}
you are overriding the internal private class variables _balance and _amount with what you pass in as _balance and _amount. Im not sure what you intended to do here. Is the class variable _amount needed? Are you trying to update _balance, or are you just attempting to deliver the would be changes just for the values or to update externally?
-Later!
-WB-
|
|
|
|
|
you are getting the error because you are not specifying the data type for the method arguments:
public int credit(_balance , _amount)
{
return _balance + _amount;
}
public int debit(_balance , _amount)
{
return _balance - _amount;
}
TRY:
public int credit(<code>int</code> _balance , <code>int</code> _amount)
{
return _balance + _amount;
}
public int debit(<code>int</code> _balance , <code>int</code> _amount)
{
return _balance - _amount;
}
|
|
|
|
|
I can't seem to find any info on how to make my application open files.
I know this sounds crazy because it's so fundamental but how do I reference a file that was used to start the application? I can choose my program to open a certain file type but of course once I click that file I get an error because I have no code that handles that situation.
Thanks
|
|
|
|
|
Okay maybe a little clarification through an example:
When you use something like "FileDialog dialog" you get the filename through "dialog.Filename" is there something like this for when you start an application up through a file?
|
|
|
|
|
You mean you want to associate a file type with your application? So when you double-click a file of that type in the Explorer your application gets launched to open it?
That's (usually) done through Explorer. My Computer|Tools|Folder Options...|File Types|New
|
|
|
|
|
No, I know how to do that... My problem is with opening a file with my application. How do I handle the file once it is used to launch the application? What references that file?
Seems like a very common thing to implement but either I'm having one hell of a brain hiccup or I just can't find info on it anywhere.
|
|
|
|
|
Aaaaah.... the file name is passed on the command-line (as it were), so in Main you refer to it as args [ 0 ] .
When I write a WinForms app that does this I write a constructor that takes the filename
MyForm ( string FileName ) { ... }
and then in Main I use
System.Windows.Forms.Application.Run ( new MyForm ( args [ 0 ] ) ) ;
what you do with it from there is up to you.
|
|
|
|
|
Thank you very much... This was such a hard thing to search for because my only understanding of it included such common basic terms like, "Open with", file, load.
I was going crazy trying to figure out the proper way to search for this topic.
|
|
|
|
|
P.S.
In Main I test the length of the args array to determine which constructor to use.
Another way is to pass the args array to the constructor and have it decide how to proceed.
|
|
|
|