code quality – Workaround for no method in a namespace in C #

I am new to C # and have a problem with the code structure. My application has:

(1) graphical interface with button Show my Ethernet address. When the user clicks on this button, the IP address of the PC is displayed.

(2) class ModbusTCPSlaveMachine. In this class I create TCPListenter and provide it with the Ethernet IP address of the PC.

In both cases, I receive a local IP address using the same method GetAllLocalIPv4. At the moment I have 2 copies of this method in the code (in classes Form and ModbusTCPSlaveMachine) which is not good I suppose. For example, in Python, I would simply put the method in a utility module. I am aware that the methods can not be located directly in the C # namespace, so I do not quite understand why.

The option I can think of is to place this function in a separate class – a utility class containing a single method (based on the Python experience). I am not sure that it is a reasonable solution in C # because this class of utilities looks like an empty container of meaning.

How can I / should I solve the problem?