[Solved] What is generics, its uses and application? [duplicate]

Generics is used to create “Type safe” collections like List, Map etc. It means that we can add only known/expected types to collections in order to avoid storing different data in one collection. For e.g //without generics ArrayList list = new ArrayList(); list.add(new Object()); list.add(new Interger()); list.add(new String()); //with generics ArrayList<String> list = new ArrayList<String>(); … Read more

[Solved] How to create byte array and fill it with random data [duplicate]

Try the Random.NextBytes method https://docs.microsoft.com/en-us/dotnet/api/system.random.nextbytes?view=netframework-4.7.2 private byte[] GetByteArray(int sizeInKb) { Random rnd = new Random(); byte[] b = new byte[sizeInKb * 1024]; // convert kb to byte rnd.NextBytes(b); return b; } If you need cryptographically safe random bytes, use System.Security.Cryptography.RNGCryptoServiceProvider instead. 7 solved How to create byte array and fill it with random data [duplicate]

[Solved] Finding Length of an Array [duplicate]

When arrays are passed into functions, they undergo array-to-pointer conversion. This means an array of type T[N] will simply decay into T*. Notice how the size information has been lost. All that remains is a pointer to the first element of the array. Here is a quote from the Standard: 4.2 Array-to-pointer conversion An lvalue … Read more

[Solved] C++ Class implementation [closed]

Although this is not a Matrix class but rather a simple Vector2 class that accepts floats this class demonstrates how you can overload the operators. class Vector2 { public: union { float _f2[2]; struct { float _x; float _y; }; }; inline Vector2(); inline Vector2( float x, float y); inline Vector2( float *pfv ); // … Read more

[Solved] Can not flip sign

You can’t do it in a completely portable way. Rather than dealing with int64_t, let us consider int8_t. The principle is almost exactly the same, but the numbers are much easier to deal with. I8_MAX will be 127, and I8_MIN will be -128. Negating I8_MIN will give 128, and there is no way to store … Read more

[Solved] How to create folder on server pc in C# [duplicate]

As explained in MSDN: Directory.CreateDirectory: You can create a directory on a remote computer, on a share that you have write access to. UNC paths are supported; Keyword here being “UNC paths”, which take the following form: \\server-name\share-name\[subdirectory-names\] So: Directory.CreateDirectory(@”\\server-name\share-name\NewFolder1″); 0 solved How to create folder on server pc in C# [duplicate]

[Solved] Must declare the scalar variable “@lblCmpUserName”

I got the solution, I made a mistake in my INSERT query. It should be like this. string query=”INSERT INTO Company_Info2 VALUES (@UserName,@Cmp_Name,@Comm_Country, @Commercial_RegNo,@Cmp_DocPath, @Cmp_EstablishDate,@Cmp_Address,@IsAddress)”; solved Must declare the scalar variable “@lblCmpUserName”

[Solved] c++, reading string from file, segmentation fault

I’ve read Your answers, search in books and changed whole idea of reading-writing 🙂 Now when I write I use: int stringSize=text.length()*sizeof(char); file.write(reinterpret_cast<char*>(&stringSize),sizeof(stringSize)); file.write(text.c_str(),stringSize); And when I read I use: int stringSize=0; string text; plik.read(reinterpret_cast<char*>(&stringSize),sizeof(stringSize)); char * tempCharArray = new char[stringSize+1]{}; plik.read(tempCharArray,stringSize); text=tempCharArray; delete [] tempCharArray; No segmentation fault/access violation since then 🙂 I guess … Read more

[Solved] How to cast a type to specific class in c# 4.0 after querying LINQ to Object

Use .FirstOrDefault() to get the first element matching your Where(), or null when none match: var oCustomer = oCust.Where(x => x.CountryCode == “US”).FirstOrDefault(); also discuss how to solve the above scenario using auto mapper with sample code. You’ve done this under various of your questions: “Here is my question, oh and please explain this related … Read more