0

Is it possible to take parameters from one method to another?

Basiclly what I want to do is rename a method (in my case is The - .WriteLine() Method), Is there any way of creating a method with the name I want and have it take the parameters of another method like so:

void Func(Take The parametes of The .WriteLine method) //This is the rename of the method
{
   Console.WriteLine(place them here);
}

Basiclly I want to rename a method.

4
  • 1
    There is no syntactic sugar for the parameters. You'd have to declare them yourself. Note that there are several overloads of Console.WriteLine(). Commented Aug 14, 2016 at 16:09
  • 1
    Are you trying to create an abstraction for the Console.WriteLine method? (So you can redirect where you want it to go when you want to.) I ask, because there might be an easier way to accomplish what you want. Commented Aug 14, 2016 at 16:11
  • 1
    What's the reason for this? Might give us a clue as to how best to advise Commented Aug 14, 2016 at 20:32
  • @Charleh Im just doing a Coco Jumbo "Skin", i want every basic command or data type to have either coco or jumbo in them. So im "renaming" them. Commented Aug 14, 2016 at 21:16

1 Answer 1

4

If I understand your question correctly, all you want to do is pass an object to Func which should be passed on to the WriteLine method.

void Func(string SomeParameter) //This is the rename of the method     
{
   Console.WriteLine(SomeParameter);
}

SomeParameter will be passed to the Func method which calls Console.WriteLine. Use this function as :

Func("Hello World");

This should print the text "Hello World" on the output screen.

Sign up to request clarification or add additional context in comments.

1 Comment

Yes. SomeParameter is a variable, a string in this case. It can accept variables of other data types also (int, decimal, char etc), see msdn.microsoft.com/en-us/library/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.