Posts filed under ‘C Sharp’

Using the Android Fused Location Provider

location-clipart-map_pinIn this post, I’ll walk you through the code in a very minimal app that just demonstrates getting locaiton. This app was created using the Xamarin Android platform, so it is written in C# but still uses the Fused Location Provider API which is provided by Google Play Services . My code is available on GitHub in a Xamarin Studio / Visual Studio solution: Geolocation Demo. (more…)

May 27, 2016 at 2:29 pm 2 comments

C# Pass-by-reference – Concept and example

670px-Pass-a-Soccer-Ball-Step-3-Version-2One of the concepts that many of my beginning programming students find difficult to wrap their heads around is the different ways that arguments can be passed when a method is called.  The two mechanisms for passing an argument to a method are pass-by-value and pass-by-reference.

(No, this post isn’t about soccer, I just wanted to get you thinking about passing.)

Advice to new programmers: Skip this paragraph. But the rest of this post is for you!
Before launching into our discussion, I need to clarify that we’re only talking about what happens when we pass value types to method parameters. Value types are the types enum and struct. The numeric types and bool type that are built into C# are all actually structs and so they are all value types. Interestingly, strings are not value types, they are reference types, but that’s a topic for another post!

I should make another clarification too. When I talk about the code that calls a method, I refer to the variables passed to the method as arguments, but when I talk about the code that defines a method, I call the variables inside the parenthesis parameters.

Pass by Value
Let’s take a look at a “normal” C# method definition:

     int Sum(int num1, int num2)    // this method returns the sum of num1 and num2
          return num1 + num2;


March 15, 2015 at 5:20 pm Leave a comment

Xamarin Android course

Xamarin Certified

Certified in 2014

Free Guest Access!
I’ve added free guest access to the first two weeks of my course here: CS235AM Moodle Course. You can log in using the “Guest” button without being enrolled as a student at the college. If you like what you see, you can enroll as a student at Lane Community College, then contact me so I can clear you to register for CRN 33368. The class starts January 8, 2018, but you can register later after cheking out the first week or two.


September 9, 2014 at 8:39 pm 1 comment

Bird’s Bits

Computers, software & the Internet

Enter your email address to follow this blog and receive notifications of new posts by email.

Join 38 other followers

All Posts