Author Archives: Malik

Program to generate Fibonacci series in C Sharp/C#

By | April 27, 2011

Hi, Here is a simple program to generate Fibonacci series using C Sharp /C#. It will generate Fibonacci numbers < 100. [csharp] class MainClass { public static void Main() { int oldNum = 1; int presentNum = 1; int nextNum; System.Console.Write(presentNum + ","); while (presentNum < 100) { System.Console.Write(presentNum + ","); nextNum = presentNum +… Read More »

How to create and delete a directory in SdCard in ANDROID?

By | April 27, 2011

Hi all…… This is a simple example to create and delete a directory in ANDROID. Here the directly is created in the SDCARD. So first create an SDCARD and start the emulator with the SDCARD. Let’s look at the program. Use can use this program to create or delete a file in ANDROID also. package… Read More »

Get files from a directory – C#/C Sharp

By | April 25, 2011

Hi, Sometimes you may need to get the files from a specified directory using C# / C Sharp. See the sample code on how it works. using System; using System.IO; class MainClass { public static void Main() { string[] yourFiles = Directory.GetFiles("c:"); foreach (string fNames in yourFiles) Console.WriteLine(fNames); } } This code will get you… Read More »

C#/C Sharp – Delete file in a folder

By | April 25, 2011

Hi, Let’s see a simple example of deleting a file in a folder using c#. using System; using System.IO; public class MainClass { static void Main(string[] args) { FileInfo sampleFile= new FileInfo(@"c:SamplestestFile.txt"); sampleFile.Create(); sampleFile.Delete(); } } sampleFile.Create() will create the file in the specified folder. sampleFile.Delete() will delete the file in the specified folder. 🙂

ANDROID – Upload an image to Server in Android Studio

By | April 25, 2011

Hi all, In today’s tutorial I will show you how to send an image to server using POST method in ANDROID. Uploading an image to server is a basic requirement in many of our application. Sending data to server which is using a PHP Script is already explained in this example . Now in this… Read More »

Showing Twitter updates on Blogger/Blogspot

By | April 24, 2011

Hi, If you want to show the latest twitter update of yours in your blogger/blogspot, then use the following steps. 1. Go to your blogger ‘Design’ 2. Click ‘Add A Gadget’ 3. Add ‘HTML/JavaScript’ 4. Paste the following JavaScript code into it and save <div class="twitter-desc"> <ul id="twitter_update_list"><li></li></ul> <script src="http://twitter.com/javascripts/blogger.js" type="text/javascript"></script> <script src="http://twitter.com/statuses/user_timeline/SampleURL.json?callback=twitterCallback2&amp;count=1" type="text/javascript"></script> </div>… Read More »

How to create a text file in C# ?

By | April 23, 2011

Hi, How can you create a text file in C# and write to it? Sometimes you may need to create a text file using C sharp program. Here is how you can do that. using System; using System.IO; class MainClass { static void Main(string[] args) { StreamWriter yourStream= null; string yourString= "I Love Coderz Heaven!";… Read More »

Identifying sprite associated with a particular body in Box2D

By | April 23, 2011

Hi, How can you identify the sprite associated with a particular body while using box2D ? Sometimes you may need to identify the sprite associated with the body you are using. For that use the following line of code. CCSprite *yourSprite= (CCSprite*)yourBody->GetUserData(); Now you got the corresponding sprite in your ‘yourSprite’ 🙂

A simple exception handling using C#

By | April 23, 2011

Hi, See how a very simple exception handling works with try-catch methods using C#. using System; class MainClass{ public static void Main(){ int divOne = 0; try { int ans = 79 / divOne ; } catch (Exception e) { Console.WriteLine("You got the exception-> " + e.Message); } } } Output- “You got the exception->… Read More »

How to find a leap year using C# ?

By | April 18, 2011

Hi, Sometimes you may need to find whether a particular year is leap year or not. But how can you find out whether a particular year is leap year or not in C# ? Use the following code. using System; class MainClass { public static void Main() { bool myResult= DateTime.IsLeapYear(2011); Console.WriteLine("Is the year 2011… Read More »

Accessing all items of an Array in C#

By | April 18, 2011

Hi, In order to access all the items of an array in C#, use the following lines of code. We are using foreach loop to access all the elements of an array in C#. using System; class MainClass { public static void Main() { string myString = "Apple Ball Cat"; char[] separator = {‘ ‘};… Read More »

How to use progress bar dialogs and custom Dialogs in ANDROID?

By | April 15, 2011

Hi, In most situations we have to use progress bar dialogs, Alert View Dialogs and Our own custom Dialogues in our applications. In most situations the built in dialogs may be enough but in certain other situations we have to build our own dialogs for better user experience. But still there is problem people don’t… Read More »

How to detect shake in iPhone ? An example

By | April 13, 2011

Hi, Sometimes you may want to detect shake gesture in iPhone using your programs. But how can you detect shake gesture in iPhone? Shake gesture in iPhone can be detected by using the accelerometer. The following lines of code can be used for detecting the shake gesture in iPhone. You can use these lines of… Read More »

How to remove box2D body from world ?

By | April 10, 2011

Hi, If you are a game developer and you are using box2D for real world simulations, you would probably need a particular body to be removed from the box2D world! But how can you remove box2D body from world ? See the following sample code which does the same. – (void)ccTouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {… Read More »

jQuery dollar sign alternative

By | April 8, 2011

Hi, Dollar ($) sign is a shortcut for jQuery. But sometimes it may have conflict with some other JavaScript library functions which also uses $ sign. What to do then? Its simple. Use jQuery noConflict() method for creating any custom names. See for yourselves. I am going to hide! Hide it! Here ‘jqNew’ is your… Read More »

How to find whether an item is in NSArray or not ?

By | April 6, 2011

Hi, Sometimes you may need to find/search a particular item in NSArray. How can you find whether a particular item is present in NSArray or not? Look at the code below. BOOL testFlag= [yourArray containsObject:@&quot;CoderzHeaven&quot;]; if(testFlag) { NSLog(@“Yup! It’s present!&quot;); } else { NSLog(@&quot;Nopes! It’s absent!&quot;); } Here ‘yourArray is your NSArray and ‘containsObject’ returns… Read More »

How to empty an NSMutableArray ?

By | April 6, 2011

Hi, Sometimes you may need to empty an NSMutableArray which is already initialized with some objects. You don’t need to release it and again alloc it for future use! You can simply empty an NSMutableArray using the following line of code. [yourArray removeAllObjects]; Here ‘yourArray’ is your NSMutableArray. 🙂