Browsing 7239 questions and answers with Jon Skeet

Does it matter for the security of AES how the byte array is encoded in C#?

I have a byte array that was encrypted using AES with the pass phrase encrypted using SHA-256. Everything works perfect, but I'm wondering about the last part where I have to...
Jon Skeet
people
quotationmark

Does it matter, for the robustness of the end result how the byte array is encrypted, Base64, conversion to hexadecimal values, something else? No, not at all. So long as you're encoding it in a lossless format (which both base64 and... more 1/28/2016 11:13:29 AM

people

compiling java package classes. Cannot access Class. class file contains wrong class while working with packages

I was trying to compile a few files in a package in java. The package name is library. Please have a look at the following details. This is my Directory...
Jon Skeet
people
quotationmark

You've got a casing issue: class Parentclass That's not the same as the filename ParentClass.class, nor is it the same as the class you're trying to use in ChildClass: class ChildClass extends ParentClass. Java classnames are... more 1/28/2016 11:05:53 AM

people

Await async TaskEx

What is TaskEx? In http://www.i-programmer.info/programming/c/1514-async-await-and-the-ui-problem.html?start=1 or await TaskEx.Delay or Await async clarification. I use Task...
Jon Skeet
people
quotationmark

TaskEx was just an extra class which initially shipped with the CTPs of the async/await extensions for C# 5 before .NET 4.5 shipped... and is now part of the Async Targeting Pack (aka the Microsoft.Bcl.Async NuGet package) in case you want... more 1/27/2016 3:37:20 PM

people

Abstract method in public abstract class implementing an internal interface doesn't compile?

internal interface I_Foo { void Bar(); } public abstract class A_Foo : I_Foo { public A_Foo() { } abstract void I_Foo.Bar(); } public class Foo : A_Foo { public...
Jon Skeet
people
quotationmark

Explicit interface implementations always have to have an actual implementation. The trick here is to making that just call a non-explicit (internal) abstract method: public abstract class A_Foo : I_Foo { // Classes outside the... more 1/27/2016 3:05:16 PM

people

Error : Index was outside the bounds of the array in c#

I'm trying write small program using c# interface concept for the area of circle & square.While Giving specific condition if (args[0] == "S") there is an error...
Jon Skeet
people
quotationmark

That will happen if args is empty. You can't ask for the first element of an empty array, because there isn't one. You should check the length first: if (args.Length == 0) { // Maybe exit? Is it valid not to specify any... more 1/27/2016 7:25:05 AM

people

C# Reflection: "Pointer" to a value type

Short description I want to know if there is a .NET feature letting me manipulate a value type obtained by reflection. So when calling PropertyInfo.getValue(...) on a value type...
Jon Skeet
people
quotationmark

So when calling PropertyInfo.getValue(...) on a value type property I want to not get a copy, but the original object and manipulate it. Then you need access to the field, not the property. Alternatively, you need to call the getter... more 1/27/2016 7:10:40 AM

people

Error array dimension missing

I keep getting array dimension missing public static Planet[] readPlanets(String filename) { allPlanets = new Planet[]; In in = new In (filename); int nplanets =...
Jon Skeet
people
quotationmark

When you create an array, you have to specify the size. I strongly suspect you want: In in = new In(filename); int nPlanets = in.readInt(); allPlanets = new Planet[nPlanets]; Note that it's odd that you're assigning to a field and... more 1/27/2016 6:57:01 AM

people

Method can only be called again if 3 seconds is passed

I want to implement some way to prevent a method from being called several times instantly. for example imagine if I have a class like: class Example { public void...
Jon Skeet
people
quotationmark

I don't see any need to use a timer here. You can use a Stopwatch: class Example { private static readonly TimeSpan MinInterval = TimeSpan.FromSeconds(3); private readonly Stopwatch stopwatch = new Stopwatch(); // Stopped... more 1/26/2016 12:10:20 PM

people

Compare two integer objects for equality regardless of type

I'm wondering how you could compare two boxed integers (either can be signed or unsigned) to each other for equality. For instance, take a look at this scenario: // case...
Jon Skeet
people
quotationmark

In case 2, you actually end up calling int.Equals(int), because ushort is implicitly convertible to int. This overload resolution is performed at compile-time. It's not available in case 3 because the compiler only knows the type of int5... more 1/26/2016 6:59:33 AM

people

Why/When should one ever force push?

I often read about how to force push, and that all commits in the remote repository that are not pulled get lost. If one doesn't need specific commits, he could also create a new...
Jon Skeet
people
quotationmark

The common reason I experience is this scenario: Master repo on github Fork also on github Clone locally Work happens locally, then is pushed up to the fork. A pull request is then created, and offered for code review. The code review... more 1/25/2016 3:12:51 PM

people