This is a common mistake among C programmers who start coding in a new environment with a new compiler such as .NET 1.1 or .NET 2.0. You get the error because the iostream.h file is no longer used with these compilers, instead use the ISO compliant file iostream: #include <iostream>;
Display Time Left To a Date
A PHP function to display the time between now and a future date supplied as Unix time, in human readable format, using two blocks of time periods (year, month, week, day, hour or minute.)
Search and replace table field contents
The query below will replace all occurences of “Bob Loblaw Law Blog” found in the field “BlogName” field of the Blogs table. All instances of the string are being replaced, and the search is case sensitive. The function is also multi-byte safe.
How do I set the type of an enumeration?
Usually you don’t specify a type for an enumeration and the default will be considered, which is int.In the following example we change the type to unsigned int (uint):
When you have to pass an array to a method, you can directly pass the values without creating the array
If you have to pass an array to the method myMethod you would usually do something similar to this: int[] myArray = new int [3] {23, 48, 96, 114};myClass.myMethod(myArray); But why create an array when you can pass the integers directly? The compiler takes care to pack the integers into an array. myClass.myMethod(23, 48, 96, 114);
How to check if a registry key / subkey already exists
The following example shows you how to check if a key in the Windows registry exists, in this case the key named Test which is situated in HKEY_CURRENT_USER\Software\Geekpedia. Registry.CurrentUser tells the program to use HKEY_CURRENT_USER. We use double backslashes to escape the slash in the registry path, but we can aswell use:
Do I need the PDB (.pdb) file when I deploy my ASP.NET application?
Program Debug Database (PDB) is not normally required for your ASP.NET web application to run, however they are required for debugging. PDB files are used to store debugging information and they are created when you compile the application. In ASP.NET, as well as other .NET applications, PDB files serve a crucial role in the debugging process. […]
Array creation must have array size or array initializer
Array creation must have array size or array initializer error is caused by a line similar to the following: And the problem with this line is that you create a new array but you don’t define a size. When you create an array you have to either define a size for the array, or declare […]
How do I get the values when submitting a form (either using GET or POST)?
This is a popular question among ASP.NET beginners, because this is done fairly different with .NET. While in PHP you would use $HTTP_POST_VARS[‘field1’] and $HTTP_GET_VARS[‘field1’] to get the value passed from a form (either using POST or GET method), in ASP.NET there is a big difference.First, if you pass the value using the GET method […]
How to retrieve the state of Caps Lock, Num Lock and Scroll Lock keys
In order to know whether or not Caps Lock, Num Lock or Scroll Lock keys are on, we need to make use of the Win32 API through a call to an unmanaged function. Since we’ll make a call to an unmanaged function, the following using statement is in order: using System.Runtime.InteropServices;The following is the definition for the unmanaged […]