TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Jose Saiz
1.5k
260
103.1k
class parameters by Ref
Jul 24 2019 5:58 PM
I need direction on HOW TO create class in C# that accept parameters by reference,
I am a bit confused with tutorial
https://www.tutorialspoint.com/csharp/csharp_reference_parameters
Back in time Visual Basic I used to create class/functions that accept parameters by Value and by Reference.
ByVal parameter needs to be passed with some value
ByRef parameter needs may be empty or has value
//- Let's assume this my function
public
string
MyObject(
int
pParamValue1,
ref
string
pParamValue2)
{
string
ResultValue =
"Your Result value is"
;
ResultValue += pParamValue1.ToString();
if
(pParamValue2 !=
null
)
{
ResultValue +=
" By Reference: "
+ pParamValue;
}
return
ResultValue;
}
//- Using the function passing the parameter by value
string
GetResult = MyObject(20);
//- Using the function passing the parameter by value and parameter by Ref.
string
GetResult = MyObject(20,
"Hello World"
);
Am I in the right path?
Thanks
Reply
Answers (
2
)
how can i change console code to win Forms
Try Catch and throw exceptions