Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

342
Vistas
PowerShell conversion of String into FileInfo automatically - What is this called?

Some sample code to illustrate what I'm talking about. I've got a utility class with a single method. That method takes one argument: a System.IO.FileInfo object. From the PowerShell side I can pass in a System.String object and everything "just works". I'm curious as a develop getting more into PowerShell this year I'm curious:

  1. What feature of PowerShell allows this to happen?
  2. Is this open to extension / use by any developer in PowerShell 7.x? (non-internal)

C#:

using System.IO;
using System.Linq;

namespace TestProject
{
    public class Utility
    {
        public string GetFirstLine(FileInfo fileInfo)
        {
            string firstLine = File.ReadLines(fileInfo.FullName).First();
            return firstLine;
        }
    }
}

PowerShell:

Add-Type -Path "C:\assemblies\TestProject.dll"
$util = [TestProject.Utility]::New()
$util.GetFirstLine("C:\temp\random-log.txt")

Note: I realize this is trivial example. Code is meant for quickly illustrating the capability in PowerShell I am interested in.

over 4 years ago · Santiago Trujillo
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda