Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
K

Kubajzz

@Kubajzz
About
Posts
39
Topics
3
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • The rain in spain...
    K Kubajzz

    VE2 wrote:

    the rain in spain falls mainly on the plain

    the rain in spain stays mainly on the plain FTFY :)

    The Lounge csharp help question

  • The perfect teacher
    K Kubajzz

    RobCroll wrote:

    I like the way they explicitly declare methods as public when the class is implicitly internal.

    I can't really see anything wrong with that :confused:

    RobCroll wrote:

    if you want to pass, hand in your assignments :)

    I have already got an A, but thanks for the offer :D

    The Weird and The Wonderful csharp java visual-studio tutorial question

  • The perfect teacher
    K Kubajzz

    Sure :) First of all, properties should be used in C# instead of get() and set() methods wherever appropriate. Public member names should start with a capital letter. Prefixes such as "arg..." are evil. The constructor parameters should be simply "name" and "sname". The name "SName" is a great example of an unclear and unneccessary abbreviation that should be avoided. I was too lazy to search for reference links, this is what I remember from the guidelines. Somebody correct me if I'm wrong...

    The Weird and The Wonderful csharp java visual-studio tutorial question

  • The perfect teacher
    K Kubajzz

    See this piece of code:

    class Person
    {
    private string name;
    private string sname;

    public Person(string argName, string argSName)
    {
        name = argName;
        sname = argSName;
    }
    
    public string getName()
    {
        return name;
    }
    
    public string getSName()
    {
        return sname;
    }
    
    public override string ToString()
    {
        return name + " " + sname;
    }
    

    }

    Now consider these few facts: - the code is in C#, not Java - in case you haven't noticed, this code violates some basic good-style C# coding guidelines - the person who wrote this code teaches C# programming at university - this piece of code was given to his students as a do-it-like-this example - he never, ever uses properties (Java-style getXXX() and setXXX() methods seem to be good enough for him...) - he sometimes names his classes and methods in Czech using diactitics (yes, it compiles fine since VS is Unicode-based, but... WTF?) - And more!

    The Weird and The Wonderful csharp java visual-studio tutorial question

  • It it just me or is SL/WCF development really flaky
    K Kubajzz

    Yes, it's just you... ;P No, seriously, I have exactly the opposite problem - working with winforms is a torture for me, while SL and WPF seems to go smoothly. I guess it's just the matter of personal preference - everybody has to find at least 1 technology to hate.

    WPF csharp announcement visual-studio winforms wcf

  • .NET code protection
    K Kubajzz

    What you want is near to impossible, or at least very difficult. I believe professional obfuscation tools might be able to do what you need, at least partially, but you can't get those for free. Anyway, no obfuscation algorithm can protect your code. If you keep your method names unchanged - probably because you need descriptive names - then your code cannot really be obfuscated. A good descriptive method name pretty much says what the method does (that's its purpose, in the end), which helps a lot to any potential reverse-engineer. As for the method body, automatic obfuscation usually only consists of renaming all identifiers and a few more well-defined steps. The algorithm has no knowledge of your code and it can only do very little because it must not break your code.

    .NET (Core and Framework) help csharp collaboration question

  • Choice of .NET Framework version
    K Kubajzz

    It really depends on the kind of application and who it is intended for. If you do not need any features of the latest version and if you do not use any libraries built with the latest version of the framework, then it might be appropriate to build your project for an older version of .NET. For example .NET 3.0 is pre-installed on all Windows Vista computers and .NET 3.5 ships with Windows 7. Therefore if you chose .NET 3.0 as your target framework, there will be more users able to use your application out of the box.

    .NET (Core and Framework) csharp dotnet winforms question announcement

  • MSIL String comparison question
    K Kubajzz

    You are welcome

    .NET (Core and Framework) question csharp dotnet

  • MSIL String comparison question
    K Kubajzz

    If HELLO_W is a constant, then the result of the comparison is known at compile time and it will always be the same. I believe the compiler is smart enough to remove such unnecessary conditions... You might get different IL code depending on the compiler settings (Release/Debug).

    .NET (Core and Framework) question csharp dotnet

  • char[] to string conversion
    K Kubajzz

    This should do the job:

    string str = new string(buffer).TrimEnd('\0');

    Or, if you know the desired length of the string, you can try this:

    string str = new string(buffer, 0, length);

    C# css question

  • Validating string values
    K Kubajzz

    If the variable is only allowed to hold certain set of values, I wouldn't use string at all... An enum is the way to go. Enums can be converted to string easily and you can also parse a string to get the corresponding enum value. If, for some reason you really need to use a string, there are several ways to validate it. Using a regular expression might be a good way to do it...

    C# csharp linq tutorial question

  • Entery key functionality in WPF textbox
    K Kubajzz

    You are welcome!

    WPF csharp wpf

  • Entery key functionality in WPF textbox
    K Kubajzz

    Make sure the AcceptsReturn property of your textbox is set to true.

    WPF csharp wpf

  • Chrome and IE8
    K Kubajzz

    I went the other way... I used to use Chrome for a long time and switched back to IE8 recently. IE is slower when rendering, scrolling, executing javascript etc... but at least it has an RSS reader and several more basic features Chrome doesn't have. And all sites work fine with IE8 (which, unfortunately, can't be said about Chrome). In the end, whichever browser you choose, you will always have several reasons to hate it...

    The Lounge csharp com tools question

  • Thread.Join() and GUI
    K Kubajzz

    I have 2 suggestions: 1. Do not use the Thread class unless you have to, because it adds a lot of complexity (could BackgroundWorker do the job?) 2. I would never use Thread.Join() unless I really had to... What if you just set a flag to notify the background thread about the cancellation and wait for the thread to complete without calling Join()?

    C# question mobile design help tutorial

  • Could use some help please.
    K Kubajzz

    Ok. I will try to ignore the fact that you provided way too much code that seems very cryptic and unreadable, while only about 10 lines are related to the error... I will ignore the fact that most of the infrotmation you provided with your code is absolutely useless and irrelevant. I will ignore the fact that the title of your first post is the second worst possible title (the first one being "PLZ HELP URGNT"). And I will also try to ignore the fact that your last post didn't contain that mysterious word starting with "tha" and ending with "nks"... If my previous advice didn't help, there is not much more I can do for you. The best help I can give you is: Read the compiler error carefully. Locate the problem in your code. Check everything on that line, see what parameters are required for each method... And then make sure that the parameters you are passing match the required type. With intellisense and all the support provided by Visual Studio (or whatever tool you use) it should not take more than 23.7865039 seconds to locate and fix such a simple error like a type mismatch... even if you are a beginner!

    C# database help csharp graphics

  • Multi-threading and function recursion with a form [modified]
    K Kubajzz

    I would personally use the AutoResetEvent class instead of Monitor. I'm not sure if I understand your problem correctly, but the WaitOne() and Set() methods of AutoResetEvent might do exactly what you need.

    C# help tutorial question

  • Need help with co/contravariance and generic lists :s
    K Kubajzz

    I'm glad it helped... Here are 2 more notes to make my answer a bit more complete. I assume you aready know all this, but it coud be useful to someone: - The System.Linq namespace is your best friend when working with IEnumerable(T). - The yield return statement is an awesome language feature... http://msdn.microsoft.com/en-us/library/9k7k7cf0.aspx

    C# help tutorial csharp linq data-structures

  • Need help with co/contravariance and generic lists :s
    K Kubajzz

    Lee Reid wrote:

    My project has several deriving classes, and values being entirely 'readonly' defeats the purpose of the whole class

    I thought you only needed the complete list for iterating through all lists, thus a read-only iterator (such as IEnumerator) could be enough. IEnumerable(T) can be implemented in a very clean way without the need of any "special programming". See the following example:

    class A {}

    class B : A {}

    class C : A {}

    class MyClass {
    private List<B> listB;
    private List<C> listC;

    public MyClass() {
    // Initialize lists...
    }

    public IEnumerable<A> GetAllItems() {
    // Get each list in this class as IEnumerable<A>
    IEnumerable<A> b = listB;
    IEnumerable<A> c = listC;

    return b.Concat(c);
    

    }
    }

    Yes, it is this simple. Note that the GetAllItems method could easily be 1-line long. You can implement some logic to get all the lists in the current class as an array of IEnumerable<A> for easy overriding, it's not more than 1 or 2 very short methods... I don't think this is messy, nor does it require any "special programming" and I highly doubt there is easier and simpler solution. The one and only question is: does IEnumerable provide enough functionality for your application?

    C# help tutorial csharp linq data-structures

  • Transform a model's positions directly
    K Kubajzz

    I don't think (c) seems like the best option, although there are some scenarious where it might be appropriate to transform each vertex (or "position") directly... The Transform property is there for a reason. You can move, rotate, scale etc. the entire model by setting just one matrix. That's far easier than transforming each vertex. There is also a good reasony why WPF stores the positions relative to the model's coordinate system. This is actually how almost every CAD program and 3D engine works. Most of the time when you are editing the shape of a model you don't really care how the model is oriented and transformed, because you only pay attention to the shape itself, that's why relative coordinates are useful. You can always get the global coordinates easily by using the model's transformation matrix. One more thing: moving each vertex of the model might be a lot slower than transforming the whole model at once. It depends on the implementation of the 3D engine, but if you set the Transform property of the model, the transformation of all vertices might be hardware accelerated, while transforming each vertex individually will definitely run on the CPU. I can't answer your question ("which method is the best") because it depends on your application... But I would try to avoid option (c).

    WPF question csharp wpf architecture tutorial
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups