Showing posts with label C# 2010. Show all posts
Showing posts with label C# 2010. Show all posts

Thursday, March 1, 2012

Difference between ref and out parameters in .NET


The out and the ref parameters are used to return values in the same variables, that you pass an an argument of a function. These both parameters are very useful when your function needs to return more than one values.


                The out Parameter
The out parameter can be used to return the values in the same variable passed as a parameter of the function. Any changes made to the parameter will be reflected in the variable.

Saturday, February 4, 2012

Write a code to get file name from file path in c#


  String filePath = @"c:\file\neme\file.txt";

=> filePath.Split('\\')[filePath.Split('\\').Length-1]     ---->   Will give file name with extension

=> (filePath.Split('\\')[filePath.Split('\\').Length-1]).Split('.')[0] --> Will give file name without extension 


=> filePath.Split('\\')[0]  --> Will give drive letter 


Live

Your Ad Here