|
To expand on what Luc said,
A ton of code and unformmated = ignored.Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Individuality is fine, as long as we do it together - F. Burns
Help humanity, join the CodeProject grid computing team here
|
|
|
|
|
Hello,
I want to ask maybe somebody know.
How I Append String To Excel File????????
I have a command for that?Like "File.AppendAllText(stringfile,stringtoappend);"!!
ThankYou.
|
|
|
|
|
1) you can use OleDB
2) use interop
Here's one of many articles on that topic
|
|
|
|
|
I dont have a simple way to do that?
|
|
|
|
|
Nope. Sure there are some comercial apps that ease the process but not as simple as
stream.Write(..);
|
|
|
|
|
Here you go again. Sure as sh*t, somebody's told you that you have to do something more complicated than Console.WriteLine("Hello World"); and off you go whinging about it. Grow yourself some balls and actually try some of the advice you've been given."WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
You have asked this question multiple times and have been told you must use interop to accomplish the task you are asking for I know the language. I've read a book. - _Madmatt
|
|
|
|
|
No matter how many times you ask this question, the answer will NOT change. You were told what you had to do back here[^].
|
|
|
|
|
noamtzu00 wrote: File.AppendAllText
So how many times are you going to ask this question before you figure out that you might actually have to work for it? You have been given the answer and you could have probably done it by now instead of asking the same question over and over.Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Individuality is fine, as long as we do it together - F. Burns
Help humanity, join the CodeProject grid computing team here
|
|
|
|
|
How can textbox control to set the money format for input?
I try to use cultureInfo but it doesn't work.
System.Globalization.CultureInfo cultur = new System.Globalization.CultureInfo("fa-IR");
InputLanguage.CurrentInputLanguage = InputLanguage.FromCulture(cultur);
|
|
|
|
|
the text box doesn't do any automatically formats for the string/values.
Format the string using string.Format() and then set the text to the text box.
Or use a masked text box with a custom mask or...
or something like:
System.Globalization.CultureInfo cultur = new System.Globalization.CultureInfo("fa-IR");
InputLanguage.CurrentInputLanguage = InputLanguage.FromCulture(cultur);
decimal moneyvalue = 1921.39m;
txextBox1.Text = String.Format("{0:C}", moneyvalue);
|
|
|
|
|
I think you suggest string.format("C").
but my language is Persian and it's not for foreign language.
|
|
|
|
|
I don't know about persian but
if in UK => £9.99
in USA => $9.99.
in Euro Countryies => 9.99 €
in romania => 9.99 RON
if it doesn't work create a custom string.format();
|
|
|
|
|
Hi, I have a basic enough problem with implementing inheritance in an interface.
Here is an example of what I would LIKE to do:
static void Main(string[] args)
{
List<ISuperString> myStrings = new List<ISuperString>();
myStrings.Add(...SOMETHING...);
Console.WriteLine(myStrings[0].containsCapitalLetters());
Console.WriteLine(myStrings[0].ToLower());
}
public interface ISuperString : string
{
bool containsCapitalLetters();
}
I have seen (and implemented) some workarounds for this, however they are a bit messy for my taste.
Basically, is it possible to either have an interface inherit from a class or to derive an interface from a class (i.e. an IString interface)?
thanks
|
|
|
|
|
What I think you really want is an extension method.
public class ExtensionMethods
{
public static bool ContainsCapitalLetters(this String)
{
bool result = false;
return result;
}
}
Usage would be
String myString = "AbcdefG";
bool containsCapitalLetters = myString.ContainsCapitalLetters(); .45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
As the string class is sealed you cannot subclass it to force it to implement your interface.
If it's just methods you want to add and you're using 3.5 or 4.0 then you can use extension methods as John suggested.
If you want to add more than methods or are using 2.0 then you will need to create a wrapper around the string class - something like this will get you started
public class SuperString : ISuperString
{
private string wrappedString;
public SuperString(string stringToWrap)
{
wrappedString = stringToWrap;
}
public static implicit operator string(SuperString superString)
{
return superString.wrappedString;
}
public static implicit operator SuperString(string stringToWrap)
{
return new SuperString(stringToWrap);
}
public bool containsCapitalLetters()
{
throw new NotImplementedException();
}
}
public interface ISuperString
{
bool containsCapitalLetters();
}
|
|
|
|
|
DaveyM69 wrote: and you're using 3.5 or 4.0
Or 2.0!
Just add
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Assembly)]
public sealed class ExtensionAttribute : Attribute
{
public ExtensionAttribute() { }
}
}
And set the compiler to C#3
|
|
|
|
|
So you're saying extension methods can be used in Visual Studio 2005? Sounds like a really good tip/trick!
|
|
|
|
|
AFAIK no, it does require the new compiler (and it would probably mess up IntelliSense on VS05), but with this trick you can target .NET 2.0 (with VS08 and higher) and still use extension methods
|
|
|
|
|
Thanks guys, however the problem goes a bit deeper than my string example
(and btw, I didn't realise a string was sealed so I suppose that turned my oversimplification on its head)
What I need is an interface to use within a function (like in the list above)
A wrapper class would work fine (and at the moment I am using a wrapper interface) but inheriting from a class to an interface would be a LOT cleaner.
|
|
|
|
|
Not really sure what your question is. Sounds like you just want to create an interface and implement it with a class. That's pretty basic C#... that's all I've gathered from your question (now that you've added the disclaimer about not using string as an example anymore because it's sealed). You might want to take a look at my StringBuilderPlus Improves Upon StringBuilder article, which makes use of interfaces and implementing those interfaces. The diagram at the bottom of the article shows the interface IString and the two classes, PlainString and StringsWrapper, that implement IString. Download the code if you want to see how that's done.
Shane5555 wrote: inheriting from a class to an interface would be a LOT cleaner
An interface cannot inherit from a class, but a class can inherit from a class. And a class can implement an interface. And an interface can inherit from an interface.
|
|
|
|
|
Shane5555 wrote: would be a LOT cleaner.
No, I'm pretty sure not.
At most you may be looking for duck-typing, but maybe not.
You may need to present your concept better.
|
|
|
|
|
Hi All,
I have some winform apps that heavily object oriently designed. Of course no design documents exist from last developers. In order to gain better insite as to what is going on in the code. Outside of using system.Diagnostics and debug.write, trace.write statements dotted all over the place and checking the stack. What debugging techniques or tips can you advise in order to get up to speed quickly? The code is using all sorts of patterns.. Factory, Provider, Decorator and now I inherited these apps and need to get up to speed quickly. Any little tips or techniques would be appreciated from you Hard Core Developers here. =)
DotNetMan
|
|
|
|
|
If the code has proper comments and descriptive names to files, folders and variables, it would make life a bit easier. You can then scan through files to get a brief idea of what is happening.
If the code too is not well documented, debugging is your friend.
|
|
|
|
|
Run it through the debugger and set breakpoints if required (and conditional breakpoints if required too). That's faster than using debug.write and such.
Draw some diagrams on a whiteboard or some paper to get an idea of how the objects are related.
I have been working with some uncommented SQL stored procedures recently and have been using ErgoNotes (hierarchical notes application) to make a nested description of the code. That might not be as useful for object oriented code (especially if it is loosely linked via interfaces and delegates), but it is one more technique you might use where appropriate.
|
|
|
|