Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
You're not supposed to create in instance. The kata only asks that you create a
Type
. The example in the description does not make this 100% clear; the only thing you're supposed to implement isKata.DefineClass()
. If you look closely at the signature of that method, you'll see that the last parameter isref myType
. Theref
modifier should tell you that your method needs to create and assign aType
object to that argument.The author supplies
CreateInstance
and uses it from within the tests (similar to how you are doing it in your code, but you are not supposed to).As for your error messages: they clearly point out where the error is happening:
SomeObject
. You are trying to access these properties fromConsole.WriteLine(...)
. Remove those lines and the error will go away. Not sure why you're trying to get randomly named properties on a type that you just created, without checking whether those properties were even included in the provided dictionary. Also: trying to read a property value of atype
when that property isn't set tostatic
obviously can't work, hence the compiler complains that it needs an instance of that type.Oh, and one more thing: think about when and where you want to create a new Assembly.
Your solution does not exactly realize the task.
You need to create a new type, which will contain requested properties. What you are doing, though, is returning
ExpandoObject
type every time. It's true that instances of this type allow for adding arbitrary properties, but these properties are added to instances, and not to the overall type.else if (bitIndex > binValueList.Count)
{
result.Append(binValue.Insert(0, "1"));
}
in this line you add one bit in the beginning of result, But tests can be like this: FlipBit(127,17).In that case you should flip 17th bit of 8bit number, but in your code you flip 9th bit
forum is not dead!)
on that line -> if (binValueList != null && bitIndex <= binValueList.Count) you check for bitIndex <= binValuelist.Count,
but test cases can be like this : FlipBit(1,2) and bitIndex can be > than binValuelist.Count,
so your result become empty and in that line -> int testBin = Convert.ToInt32(result.ToString(), 2); you have error.