Hot answers tagged

87

Single can store much more numbers than Integer No, it can't. Both Single and Integer are 32 Bit, which means that both can store the exact same amount of numbers, namely 232 = 4294967296 distinct numbers. Since the range of Single is clearly larger than that, it is immediately obvious (because of the Pigeonhole Principle) that it cannot possibly represent ...


51

It depends. Check out Bart van Ingen Schenau's answer to determine if it's possible to ignore the packages folder at all. Basically: yes, NuGet is designed so that you can ignore the packages folder and NuGet will pull everything from the Internet if it's missing. But should you ignore it? I say: it depends. IMO it's a question of "can we continue working ...


30

The basic rule for what goes into a source control repository is that you store there everything related to a project that you need to be able to build, test, deploy and execute the project and which can not be generated from items already present in the repository. In other words, if you can throw away the PACKAGE folder and its contents without affecting ...


29

Use private set when you want setter can't be accessed from outside. Use readonly when you want to set the property only once. In the constructor or variable initializer. TEST THIS: void Main() { Configuration config = new Configuration(); config.ResetConfiguration(); ConfigurationReadOnly configRO = new ConfigurationReadOnly(); configRO....


29

A lot of time has passed, and NuGet has changed, so here's a new answer. NuGet no longer creates a packages folder inside your source structure. Instead there is one in your user directory (%HOME%\.nuget\packages to be specific) where it puts all packages it downloads, and projects just reference these. So the simple answer these days is no, you shouldn't. ...


28

Floating point types (such as Single and Double) are represented in memory by a sign, a mantissa and an exponent. Think of it as scientific notation: Sign*Mantissa*Base^Exponent They - as you may expect - use base 2. There are other tweaks that allow for representing infinity and NaN, and the exponent is offset (will come back to that), and a shorthand for ...


25

Here is an actual example of when converting from Integer to Single may lose precision: The Single type can store all integers from -16777216 to 16777216 (inclusive), but it cannot store all integers outside of this range. For example, it cannot store the number 16777217. For that matter, it cannot store any odd number greater than 16777216. We can use ...


22

If you consider translation to be important in your project, the first syntax will really help with it. For instance you may have: static final string output_en = "{0} is {1} years old."; static final string output_fr = "{0} a {1} ans."; int age = 10; string name = "Henri"; System.out.println(string.Format(output_en, name, age)); System.out.println(...


22

Robert Harvey's advice is likely best, but since career advice is off topic, I'll give what answer can be given: You are at the bottom of a very steep mountain covered in brambles and mud and irritable mountain goats. There's no easy way up. If you want to get to the top, you've got to force your way up one tremendously painful step at a time. It seems ...


16

Drop that "background" out of your head - it's useless for the assignment you've got. For both programs, do the same: read the code, file by file, line by line. Anything that doesn't feel right, add it to the list of issues. Typos, duplicate or dead code, things that are hard to understand, IDE/compiler warnings, anything. Use free form comments, don't ...


15

Your new developer can help you refactor the code. That will be his training (getting familiar with your software). Hire someone that already knows interfaces, polymorphism and agile. Implement a source control system yourself, if necessary.


15

Before .NET 4.0, VB.NET had a slight advantage over C# when calling COM interop code. This was especially true for code, such as the Office programmability model which, as mortalapeman notes, makes use of COM's support for optional parameters. This API often exposed methods with 10, 15 or more parameters (ugh!), all of which were ref params, which in C# had ...


15

VB does have this functionality, however the syntax is a bit different (obviously) than C#. Try (New SqlCommand("some string", someSqlConnection)).ExecuteNonQuery(). Basically, adding the parenthesis around the instantiation of the object tells it to first create the object, then call the method. The code in the question, on the other hand, is trying to ...


14

They are fully deployable to Linux environments using the Mono framework which is not controlled by Microsoft. I'd say ignoring them because you like Linux would be a mistake. If you don't like the languages for other reasons like syntax or memory overhead or whatever, then fine but I'd not write them off because they are based on work done at Microsoft and ...


12

Common Language Specification is a key It would be better to enhance your understanding of how to write a Common Language Specification (CLS) compliant code. I believe that would resolve most of the issues that you have faced or found. Basically, CLS compliance refers to CLS rules and restrictions that being followed. However, the concept has a more ...


12

If you currently have VB.NET devs who know C#, I don't think all 20 applications need any rewriting all at once. It's just too much coding, testing, rolling out and for what? Because your next few hires won't understand the code? Don't confuse C# coders who just hate VB with their not being able to understand it at all or with little training. I would do ...


12

Floating point types are similar to "scientific notation" in physics. The number is split up into a sign bit, an exponent (multiplier) and a mantissa (significant digits). So as the magnitude of the value increases the step size also increases. Single precision floating point has 23 mantissa bits, but there is an "implicit 1", so the mantissa is effectively ...


10

Chances are that this method only supports the Basic Multilingual Plane of Unicode. That Plane contains the lower 64k of codepoints and can be represented with a 16 bit data type. There was a time when the BMP was all the Unicode standard defined and at that time many languages and/or runtimes added "Unicode support". They thought that 16 bit will always be ...


10

Instead of trying to tell you what you should do, I'll share what we did. Tests get written in C#, because, let's be honest, the VB codebase doesn't have any. New classes are written in C# inside new class library projects added to the solution(s). Small modifications to existing VB code are maintained in VB, but characterization tests are added before ...


9

I think your question is related to whether you can get a job as a VB.NET developer. You can get VB.NET jobs, they do exist - but don't restrict yourself by something as unimportant as a language. Learn C# and then you can choose from a much bigger range of jobs. All of your understanding of the .NET framework is immediately useful if you switch to C#, so ...


8

Check out the first answer for https://stackoverflow.com/questions/4671610/why-use-string-format. It covers everything in my opinion as to why it is better. Also, each .NET assembly has an intern pool, containing a collection of unique strings. When your code is compiled, all the string literals you reference in your code are added to this pool. If you have ...


8

I don't know about the converter's and if it's gonna make you lose anything(performance wise). But I am sure about one thing, learning a new language would not hurt your resume. It's always good in my opinion to learn something new and considering your case: The company's major language is VB, you'll get along with the whole work environment far better. It ...


8

Despite both languages running on the .NET Framework, they have some differences that can make certain things easier or even possible in VB that aren't in C#, and vice versa. Some things off the top of my head: The VB version of the Application class has a SplashScreen property. When set to a Form in the main method, that Form will show when Application....


8

Well, first of course, you are going to have lots of queries because you expect the application to do lots of things. Databases have a couple of things that can help, but you can make things worse by using them badly. ORMs are one tool that will help write the queries for you. But you will still have a lot of queries if you have a lot of database work ...


8

It depends not just on the problem domain, but also on technical considerations. Basically, it comes down to the simple question: "Will there be unacceptable problems when a partial update happens?" Some examples: Transfering money from one account to another. A partial update is completely unacceptable for domain reasons. Adding a vote to an online poll ...


8

1) Debugger cannot be used on client site ... That's perfectly normal. ... or locally Now that's a problem. 2) There is virtually no logging done in our apps. Logging is the Production Debugging. There are no unit tests. Oh dear. All to common, though. 3) Version control only has 1 version of the full solution Then you're not using ...


8

Single precision floats have 24 bits of precision. Anything over that is rounded to the nearest 24-bit number. It might be easier to understand in decimal scientific notation, but keep in mind actual floats use binary. Say you have 5 decimal digits of memory. You can choose to use those like a regular unsigned int, allowing you to have any number between 0 ...


7

From the Me documentation on MSDN: The Me keyword behaves like either an object variable or a structure variable referring to the current instance. The use case described is that of passing the current object to another one.


7

You are correct up to this question: So I think my understanding is correct that setting a private variable is just a construct to be able to implement the get and set pattern? Quite the opposite is true. Ideally, only the encapsulating object should have direct access to the object(s) it encapsulates. This is known as the Law of Demeter. In reality, ...


7

A lot of people these days (based purely on my professional exposure) are now using ORM tools for the benefits they provide. Benefits include: Lazy loading Multiple database targets For some frameworks, use of LINQ to select records (i.e. Linq-to-SQL, Entity Framework) Not having to change multiple queries when you add a field The primary negative as far ...


Only top voted, non community-wiki answers of a minimum length are eligible