You're viewing a single thread.
All comments
41
comments
Where are your gods now?
public static Joke getTheJoke(Meme yourMeme) { Field jokeField = Meme.class.getDeclaredField("joke"); jokeField.setAccessible(true); return (Joke) jokeField.get(yourMeme); }
36 0 ReplyIs it Java? It looked like
Microsoft JavaC# to me...public static void Main(string[] args) { var meme = new Meme(); var joke = GetTheJoke(meme); } public static Joke GetTheJoke(Meme theMeme) { var memeType = typeof(Meme); var jokeField = memeType.GetField("Joke", BindingFlags.NonPublic | BindingFlags.Instance); return (Joke)jokeField.GetValue(theMeme); }
14 0 ReplyThere isn't an unnecessary level of capitalization; seems to be regular Java with Allman braces.
4 0 ReplyFrankly it's been a while since I wrote either one. I just assumed Java because of the naming convention, and I didn't see anything I took as obviously un-Java in the class definition
4 0 ReplyBecause C# is a Java clone
2 0 ReplyIf you have to cast your joke it isn't funny?
1 0 ReplyCould just change it to public static Object GetTheJoke, no?
1 0 Reply
41
comments
Scroll to top